通过本文主要向大家介绍了c#textbox,c#中textbox控件,c#textbox换行,c#textbox多行显示,c#textbox滚动条等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
方法1:以textbox为例
①:先设置textbox的属性Multiline为true
②:组织好显示字符串:FistLine(第一行要显示的字符)、SecondLine(第二行要显示的字符)、。。。。。。。、第n行字符
③textbox.text="FistLine"+System.Environment.NewLine+"SecondLine"+System.Environment.NewLine+。。。。+"第N 行"+System.Environment.NewLine
当你看到上面代码的时候可能会认为我们一般用的换行符不是"\r\n"吗
你会想到这种方式:textbox.text="FistLine"+“\r\n”+"SecondLine"+"\r\n"+。。。。+"第N 行"+"\r\n"
这种格式可能在运行时也不会出错,但在Linux操作系统或其他系统可能就会出错
WinForm的 textbox截图效果:
Textbox例子1用("\r\n"):具体代码:
源码:
</div>