InfoPath中的Rich Text Box中如何加“回车”
来源:互联网 发布:js如何获取访客ip 编辑:程序博客网 时间:2024/05/21 06:31
InfoPath中的Rich Text Box的内容使用的是XHtml的格式,所以"\n"格式内容是不会表现出来的。
如果我们需要在Rich Text Box中添加两行内容的话,我们可以用下面的代码。
XPathNavigator f1 = MainDataSource.CreateNavigator(); XPathNavigator f2 = f1.SelectSingleNode("/my:myFields/my:field2", NamespaceManager); XmlReader xr = XmlReader.Create(new StringReader("<div xmlns=""http://www.w3.org/1999/xhtml/"> abc </div>")); f2.AppendChild(xr); xr = XmlReader.Create(new StringReader("<div xmlns=""http://www.w3.org/1999/xhtml/">def</div>")); f2.AppendChild(xr);
这样就可以换行了。
InfoPath中的Rich Text Box是XHtml的格式,所以用\r\n或是用System.Environment.NewLine,都不會換行。
使用下列程式碼即可。
public void CTRL27_5_Clicked(object sender, ClickedEventArgs e){ // 在此處寫入您的程式碼。 XmlReader xr; XPathNavigator root = MainDataSource.CreateNavigator(); XPathNavigator RichTextBox = root.SelectSingleNode("/my:myFields/my:ShowValue", NamespaceManager); string id = "12"; string name = "余小章"; xr = XmlReader.Create(new StringReader("<div xmlns=\"http://www.w3.org/1999/xhtml\">" + id + "</div>")); RichTextBox.AppendChild(xr); xr = XmlReader.Create(new StringReader("<div xmlns=\"http://www.w3.org/1999/xhtml\"> "+name+" </div>")); RichTextBox.AppendChild(xr);}
或是使用
public void CTRL29_5_Clicked(object sender, ClickedEventArgs e){ string id = "12"; string name = "余小章"; string str = string.Empty; XPathNavigator domNav = MainDataSource.CreateNavigator(); string xhtmlRTFField = domNav.SelectSingleNode("/my:myFields/my:ShowValue", NamespaceManager).InnerXml; str += "<div xmlns=\"http://www.w3.org/1999/xhtml\">" + id + "</div>"; str += "<div xmlns=\"http://www.w3.org/1999/xhtml\">" + name + "</div>"; domNav.SelectSingleNode("/my:myFields/my:ShowValue", NamespaceManager).InnerXml = str;}
以上方法都可以換行
http://www.cnblogs.com/IsNull/archive/2010/09/21/1832870.html
- InfoPath中的Rich Text Box中如何加“回车”
- 如何把一个RTF(Rich Text Field)中的信息显示在一个Notes视图中?
- c# rich text box add text into cursor position
- Infopath Form Service示例:如何在InfoPath表单中引用SQL SERVER 中的数据?
- 如何在InfoPath表单中引用SQL SERVER 中的数据?
- Rich Text
- Rich Text
- Unity3d读取CSV中的文本到Rich Text中换行符不识别的问题
- xml内容中加回车
- 如何清除 InfoPath Form 中的.Net 代码?
- SharePoint 2013/2010 使用JavaScript 将Div转换(render)成 Rich Text Box
- 关于存在Rich Text Editor的页面应该如何处理?
- 数据库的索引,mysql中的索引|||如何在mysql中对text字段加索引?|||mysql数据库中的字段在什么情况下加索引?|||高手请进:text字段不能做索引,有无其他方法?|||该建那个字段
- CSS中box-shadow、text-shadow用法
- jquery mobile中checkbox包含text box
- TextView实现Rich Text
- Rich Text Processing
- 微信小程序 rich-text
- TCP协议三次握手过程分析
- 滚 动 图 片 代 码
- HDU-2444 二分图匹配
- 卡扎菲终于over了
- java中使用MD5加密算法进行加密
- InfoPath中的Rich Text Box中如何加“回车”
- 为什么我按CTRL+空格键就会关闭程序
- java中使用SAX解析器解析xml文件
- Parse CPU to Parse Elapsd%
- VB.NET之旅(四)—类和结构
- DELPHI的美化插件VCLskin
- MySQL配置文件my.cnf中文版
- NSObject相关定义
- hibernate 二级缓存