Multi-line Rich Text Control with lines

D

DD

I need a rich text field that has the lines under each line. Like your typing
on note book paper. Any suggestions on how to accomplish this in infopath?
 
S

S.Y.M. Wong-A-Ton

You can use the fact that lines in a rich text box are created using DIVs and
then put a style on these DIVs to produce lines.
 
S

S.Y.M. Wong-A-Ton

Sure!

Rich text fields consist of HTML as content. These HTML tags are child nodes
of the XML node representing the rich text box field. You can get to these
child nodes by using code. If you add <div> elements as child nodes of the
rich text box field, you will get lines. To make these lines visible, just
give the bottom border of each <div> element a color.

Try this: Make sure the programming language of your form is set to JScript
by going to Tools > Options > Design tab > Default programming language. Add
a rich text box to your form and make sure its name is "field1". Go to Tools
Programming > On Load Event to add an OnLoad event handler for your form.
Copy and paste the following code in the OnLoad event.

var rtfNode = XDocument.DOM.selectSingleNode("//my:field1");
var childNode = XDocument.CreateDOM();
childNode.loadXML("<div xmlns=\"http://www.w3.org/1999/xhtml\"
style=\"border-bottom:#CCC 1px solid; width:100%; padding:5px;\"></div>");
rtfNode.appendChild(childNode.documentElement);
var childNode2 = XDocument.CreateDOM();
childNode2.loadXML("<div xmlns=\"http://www.w3.org/1999/xhtml\"
style=\"border-bottom:#CCC 1px solid; width:100%; padding:5px;\"></div>");
rtfNode.appendChild(childNode2.documentElement);

This will add 2 lines in the rich text box when the form loads. Preview your
form. This is the closest you will get to having lines in a rich text box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top