新文章

2012年12月27日 星期四

[C#]New line in TextBox


We can use "\n" in string to newline.
But it's not work in TextBox.

We need to use Environment.NewLine Variable to solve this problem

Mistake:


string test = "line 1 \n line 2 \n line3 ";
textbox1.Text=test;

Correctness:


string test = "line 1 "+ Environment.NewLine + "line 2 "+ Environment.NewLine +"line3 ";
textbox1.Text=test;

沒有留言:

張貼留言