How to enter multiline text in textbox through code?

Posted by vishalneeraj-24503 under C# category on | Points: 40 | Views : 756
If we dot not have multi-line text-box or we do not set Textbox as Multiline,then we can enter text as multi-line through code:-

For Example:-

1st way:-

Using Multiline and Lines Properties of Text-box as well as String Array
string [] str_address = {"Vishal Neeraj","Plot no-47 room no-6","Pune,Maharashtra,India"};

text_address.Multiline = true;

text_address.Lines = str_address;

2nd way:-

Using \r\n carriage-return
text_address.Text = "Vishal Neeraj\r\nPlot no-47 room no-6\r\nPune."

3rd way:-
Using System.Environment.NewLine

text_address.Text = "Vishal Neeraj" + System.Environment.NewLine + "Plot no-47 room no-6 " + System.Environment.NewLine + "Pune.";

text_address.Multiline = true;

4th way:-
Using vbCrLf in Vb.Net

text_address.Text = "Vishal Neeraj" + vbCrLf + "Plot no-47 room no-6 " + vbCrLf + "nPune."

text_address.Multiline = True

Comments or Responses

Login to post response