当前位置:网站首页>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 control: switch switch button control
- 在产业互联网的概念刚刚出现时,人们仅仅只是将其看成是一个获取B端流量的方法
- 百货中心供应链管理系统
- How to use clion to debug a project built by the make tool
- 基于ESP32CAM实现WebSocket服务器实时点灯
- Evolution in the digital age
- Tidb implementation plan -- I
- Fundamentals of assembly language: register and addressing mode
- 【硬记】脏读、不可重复读、幻读场景核心区别
- JMeter encryption interface test
猜你喜欢
Powerdispatcher reverse generation of Oracle data model
SDN基本概述
[Markov chain Monte Carlo] Markov chain Monte Carlo method sampling prior distribution
Implementation of fruit mall wholesale platform based on SSM
How to make a development board from scratch? Illustrated and illustrated, step by step operation for you to see.
Table access among Oracle database users
Test development programmers, are you still confused? You can't define yourself as a yard farmer
Br tool backup recovery
Fe of mL: introduction to vintage curve /vintage analysis, calculation logic and detailed introduction to case application
Nfv basic overview
随机推荐
Lightning data import
How worker threads in the thread pool are recycled
怎么写出一份令人惊叹的设计文档?
Sorting of numbers and strings
First day of learning MySQL Basics
测试开发程序员,你还在迷茫吗?不能把自己定义为码农......
[RS-422 and RS-485] RS-422 and RS-485 serial interface standard
How to use clion to debug a project built by the make tool
部署RDS服务
[Tencent Alibaba's most comprehensive collection of test questions] (four sides: three rounds of technology +1 round of HR)
Tree list under winfrom treelist related
Reflection of C # Foundation
Sharp weapon tcpdump
2022-06-12:在N*N的正方形棋盤中,有N*N個棋子,那麼每個格子正好可以擁有一個棋子。 但是現在有些棋子聚集到一個格子上了,比如: 2 0 3 0 1 0 3 0 0 如上的二維數組代錶,一
线程池中的 工作线程如何被回收
微隔离(MSG)
Continuous management design
基于FPGA的ds18b20温度传感器使用
SDN basic overview
10 Honest Facts I Want To Share With All Junior Developers