Tuesday, August 24, 2010

How to insert a new line in a TextBox


To insert a new line in a TextBox, first make sure you have the MultiLine property of the TextBox set to True.
Do not try to use \r\n (carriage return and new line) because is not going to work, instead you must use:

Environment.Newline

Example:
TextBox1.Text = "First line" + + Environment.NewLine + "Second line";


This is working since C# 1.1

No comments:

Post a Comment