Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do c# textbox.AppendText() newlines disappear when using \n as line terminator?

Tags:

I am using a multiline textbox, and I am getting behavior I cannot fully explain. I use

 textbox.AppendText("line \n"); 

to append a new line to a textbox. When using this 3 times, I get

line 
line 
line

displayed in the textbox. Now, I resize the textbox. The text becomes

line line line 

That is, the newlines disappear. I know I should be using

 textbox.AppendText("line "+ Environment.Newline);

So I know how to solve the problem. I would like to know why, when using "\n", the newlines initially appear, but disappear when resizing.