how to add multiple new lines in richtextbox?

poringgunner

Active member
Joined
Feb 23, 2014
Messages
42
Programming Experience
Beginner
how can i add new lines in richtextbox? i already use environment.newlines. but it only add 1 line..
i want to add multiple new lines. look at this example
Richtextbox1 contents
asdasdasd
asdasd
asdasd
asdasd
asdasd
asdasd
asdasd
asdasd
asdasd
asdasd
asdasd


and.

richtextbox2 contents
asda
asda
asd
asd
asd
..

i want to add empty new lines in richtextbox2 in order to equal the lines of the two richtextboxes
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,277
Location
Sydney, Australia
Programming Experience
10+
If you only add one Environment.NewLine then you'll only add one new line. If you want multiple new lines then you have to add multiple instances of Environment.NewLine or, in C#, "\r\n". Mind you, I think that a RichTextBox converts all line breaks to just a line feed anyway, discarding any carriage returns.
this.richTextBox1.AppendText(string.Format("{0}first{0}second{0}third", Environment.NewLine));
 
Top Bottom