JustASimpleGuy
JustASimpleGuy

Reputation: 181

Creating a newline in rich text box

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;
}

Upvotes: 8

Views: 38201

Answers (2)

MRebai
MRebai

Reputation: 5474

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." );

Upvotes: 14

Alexander Bell
Alexander Bell

Reputation: 7918

You can use c# Environment.NewLine Property as described in http://msdn.microsoft.com/en-us/library/system.environment.newline%28v=vs.110%29.aspx. Or, the "old style" like @"\r\n".

Rgds,

Upvotes: 0

Related Questions