Newline in C# TextBox
To insert a new line in C# TextBox, "\r\n" or System.Environment.NewLine must be used and NOT just "\n". That is, a new line is a carriage return followed by a line feed, analogous to what we have in conventional type writers.
Example:
MyTextBox.Text = "Hello\r\nWorld";
and
MyTextBox.Text = "Hello" + System.Environment.NewLine+"World";
works, but NOT
MyTextBox.Text = "Hello\nWorld";
2 Comments:
Hi There,
The post was really helpful.
Keep posting.
Cheers
Many Thanks :)
Post a Comment
<< Home