Click here to Skip to main content
15,923,789 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
disp.Text += done + "\n";//Why is this not generating a new line in the richtext box
disp.Text = disp.Text + "\n" + (done);//This line is generating a new line in richtext box
Posted

If you want to append text to a rich text box, you should use the AppendText function, like:

C#
disp.AppendText(done);
disp.AppendText(Environment.NewLine);


See RichTextBox.AppendText[^]

And

Environment.NewLine[^]
 
Share this answer
 
Yes, it is: right at the bottom, it adds a new line. But because it is blank, you can't see it, or tell it is there unless you move the input cursor to the end of the RichTextBox. Try this:
C#
private void button1_Click(object sender, EventArgs e)
    {
    richTextBox1.Text += "Hello" + "\n";
    }

private void button2_Click(object sender, EventArgs e)
    {
    richTextBox1.Text += "\n" + "Hello";
    }
And you will see what I mean.
 
Share this answer
 
You have to append with
Environment.NewLine
it should work for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900