当前位置:网站首页>C#合并多个richtextbox内容时始终存在换行符的解决方法
C#合并多个richtextbox内容时始终存在换行符的解决方法
2022-06-13 07:14:00 【gc_2299】
之前的文章《C#合并显示多个richtextbox和textbox控件中的内容》介绍了如何将不同richtextbox控件内容合并在一起,且不改变内容格式。但在实际使用时,将两个richtextbox控件的内容合并显示在另一个richtextbox中时,总是会显示为两行,而非将两段内容拼在一起,结果如下图所示:
调试程序,查看第一个richtextbox中的rtf内容(如下所示),rtf内容的最后自带\r\n换行符,最初以为是这个原因,在拼接rft内容之前,调用string.TrimEnd函数去掉\r\n,但是没有效果,拼接内容后还是会变成两行。
“{\rtf1\ansi\ansicpg936\deff0\nouicompat\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 GDT;}{\f1\fnil\fcharset134 Microsoft YaHei UI;}}\r\n{\*\generator Riched20 10.0.17763}\viewkind4\uc1 \r\n\pard\kerning2\f0\fs21 xyz\kerning0\f1\fs18\lang2052\par\r\n}\r\n”
接着查看richtextbox控件的属性或函数,看是否有控制自动换行的属性或函数,首先找到的是WordWrap属性,该属性指示多行编辑控件是否自动换行,默认值为True,将属性值修改为False,再运行程序,还是拼接为两段。
随后抱着试试看的心态,将richtextbox中的Multiline属性修改为False,该属性控制编辑控件的文本是否能够跨越多行,从属性的说明来看,看不出该属性会自动在不同内容间插入换行符,但是将Multiline属性修改为False后,再执行程序,即可将两段内容合并为一行。由于实际使用时不会出现多行的情况,就没有去管两段内容拼起来超过一行的情况。
上述测试都是使用的VS自带的richtextbox控件,如果使用dev控件中的richtextbox控件,其document属性中自带appendrtf和appendtext函数可以自动将内容合并在一起且不会换行。
边栏推荐
- Interview questions must be asked - Optimization of large table Pagination
- June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
- Through the function seaborn cubehelix_ Palette build order palette
- 全志V3S环境编译开发流程
- How to use clion to debug a project built by the make tool
- 学习Mysql基础第一天
- 理財產品連續幾天收益都是零是怎麼回事?
- RT-Thread 模拟器 simulator LVGL控件:button 按钮样式
- 个人js学习笔记
- Upper computer development (code debugging of firmware download software)
猜你喜欢
Upper computer development (detailed design of firmware download software)
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
尝试使用RenderDoc查看UE的Shader代码
FSM状态机
通过函数seaborn.cubehelix_palette生成顺序调色板
Xuanwu cloud technology passed the listing hearing: the performance fluctuated significantly, and chenyonghui and other three were the controlling shareholders
在 localStorage 中上传和检索存储图像
TiDB Lightning
Differences between SQL and NoSQL of mongodb series
Micro isolation (MSG)
随机推荐
mysql中时间字段 比较时间大小
Issues related to C # delegation and events
在 localStorage 中上传和检索存储图像
Powerdispatcher reverse generation of Oracle data model
RT-Thread 模拟器 simulator LVGL控件:button 按钮事件
Learning notes of MySQL series by database and table
c#高級編程-特性篇
个人js学习笔记
杭州网上开户是安全的吗?
2022-06-12:在N*N的正方形棋盘中,有N*N个棋子,那么每个格子正好可以拥有一个棋子。 但是现在有些棋子聚集到一个格子上了,比如: 2 0 3 0 1 0 3 0 0 如上的二维数组代表,一
An example of CSRF attack defense in web application scenarios
Department store center supply chain management system
不间断管理设计
Time field comparison time size in MySQL
No configure file found when compiling PHP from source code
RT thread simulator lvgl control: button button event
Number of detection cycles "142857“
Relevant knowledge under WinForm
Performance tuning can't just depend on tapping the brain
Tidb index optimization