c#里面TextBox控件显示数据不换行的问题

来源:百度知道 编辑:UC知道 时间:2024/05/19 18:01:05
string temp = "haha\nheihei";
textBox1.Text = temp;
如何使他显示出来换行?我已经设置过textBox1的Multiline为true了,但是还是不行

在Page_Load中加上一句试试:
TextBox1.Attributes.Add("style", "overflow-y:hidden")

string temp="haha"+Environment.NewLine+"heihei";
textBox1.Text=temp;

上面的Environment.NewLine获取当前系统的换行符。有时候\n不好用,就试试\r\n,实在不行,就用Environment.NewLine.

string temp = "haha\r\nheihei";
textBox1.Text = temp;
改成这样就可以了

用\r\n
string temp = "haha\r\nheihei";

限制没行显示的字符数不就好了

在 你输入的东西后面加上/br