Techie Talks

Thursday, April 14, 2005

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:

Blogger Shashi Singh said...

Hi There,

The post was really helpful.

Keep posting.

Cheers

2:00 AM  
Blogger Unknown said...

Many Thanks :)

9:17 PM  

Post a Comment

<< Home