Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Show New Line command in text box?

Hi i am doing a small project in C#, and i need to know what commands are comming from input source so i can do my work accordingly.. here is example...

textBox1.Text = "First line \nSecond line";
richTextBox1.Text = "First line \nSecond line";

Richtextbox shows this output:

First line

Second line

Textbox show this output:

First line Second line

please tell me how to show new line "\n" or return "\r" or similar input as a character output in text or richtextbox. so i can know that newline command is coming from input data.

for example text or richtext box will show this output.

First line \nSecond line

thankx in advance.

like image 474
user777304 Avatar asked Mar 22 '12 04:03

user777304


2 Answers

Lets say that i have a string which have new line :

 string st = "my name is DK" + Environment.NewLine + "Also that means it's my name";

Now that i want to show that there is new line in my text there you go :

 textBox1.Text = st.Replace(Environment.NewLine, "%");

This will show the newline chat with % sign

like image 134
Dhananjay Avatar answered Oct 05 '22 22:10

Dhananjay


For winforms application set

this.textBox1.Multiline = true;

and use "\r\n" as

textBox1.Text = "First line \r\nSecond line";
like image 37
ABH Avatar answered Oct 06 '22 00:10

ABH