Thursday 20 December 2012

Programmatically add lines of text to a Rich Text Box field on an InfoPath form using C# code

Following the Code:-

XPathNavigator nav = MainDataSource.CreateNavigator();
XPathNavigator rtfNav = nav.SelectSingleNode("//my:rtfField", NamespaceManager);
XmlDocument doc = new XmlDocument();
XmlElement elm = doc.CreateElement("div", "http://www.w3.org/1999/xhtml");
elm.InnerText = "Line 1";
doc.AppendChild(elm);
rtfNav.AppendChild(doc.DocumentElement.CreateNavigator());
doc = new XmlDocument();
elm = doc.CreateElement("div", "http://www.w3.org/1999/xhtml");
elm.InnerText = "Line 2";
doc.AppendChild(elm);
rtfNav.AppendChild(doc.DocumentElement.CreateNavigator());

No comments:

Post a Comment