当前位置:网站首页>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函数可以自动将内容合并在一起且不会换行。
边栏推荐
- RT-Thread 模拟器 simulator LVGL控件:button 按钮样式
- What languages can be decompiled
- Evolution in the digital age
- The biggest highlight of wwdc2022: metalfx
- Problems encountered during commissioning of C # project
- 数字时代进化论
- RT-Thread 模拟器 simulator LVGL控件:switch 开关按钮控件
- 关于c#委托、事件相关问题
- Simple understanding of basic language of C language
- Interview questions must be asked - Optimization of large table Pagination
猜你喜欢
Tikv key performance parameters and optimization
通过函数seaborn.cubehelix_palette生成顺序调色板
Upper computer development (detailed design of firmware download software)
Test development programmers, are you still confused? You can't define yourself as a yard farmer
How worker threads in the thread pool are recycled
10 Honest Facts I Want To Share With All Junior Developers
Evolution in the digital age
Normalizing y-axis in histograms in R ggplot to proportion
First day of learning MySQL Basics
RT-Thread 模拟器 simulator LVGL控件:slider 控件
随机推荐
Problems encountered during commissioning of C # project
FTP_ Manipulate remote files
RT thread simulator lvgl control: slider control
Monotone stack top31 of interview must brush algorithm top101
RT thread simulator lvgl control: button button event
Through the function seaborn cubehelix_ Palette build order palette
What does my financial product mean in clearing?
oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
同花顺可以开股票账户吗?安全吗?
Ticdc introduction
Xuanwu cloud technology passed the listing hearing: the performance fluctuated significantly, and chenyonghui and other three were the controlling shareholders
【转】FPGA面试题
[turn to] FPGA interview questions
Test development programmers, are you still confused? You can't define yourself as a yard farmer
在 localStorage 中上传和检索存储图像
Application of DS18B20 temperature sensor based on FPGA
Introduction and use of dumping
Learning notes of MySQL series by database and table
微隔离(MSG)
Tidb dashboard modify port