Creating a newline in rich text box
25,306
Use the RichTextBox.Text
property or the RichtTextBox.AppendText
method to append a string with a newline.
myRichTextBox.Text += Environment.NewLine + "My new line.";
// Or
myRichTextBox.AppendText( Environment.NewLine + "My new line." );
Comments
-
JustASimpleGuy almost 4 years
I need help on creating a new line for my RichTextBox which I cant make work when using CheckBox.
It keeps overlapping instead of creating a newline of words.
Tried using the method of
rtbdisplay.text = (display+envrionment.newline);
example from my code:if (rbtnSmall.Checked == true) { rtbDisplay.Text = "displaytext".PadRight(20) + "size".PadRight(23) + qty.ToString().PadRight(20) + StrongDummy; }
-
JustASimpleGuy almost 10 yearswhat if I wan to display the new line with my variable instead of "my new line" . i tried using my variable switching it with "my newline" still same problem
-
Tom Bogle almost 5 yearsWorth noting: Even if you append Environment.NewLine, in RTF, only the \n is retained. If you look at the Text property, you will see that the \r is gone.
-
user3607601 over 2 yearsRecently encountered this causing issues because the length of my input string and the
Environment.NewLine
added together were greater than the total text length after usingAppendText
.