Hello,

I have a richtextbox which I write lines of data to. However, everytime a new line is written to the richtextbox it overwrites the last line of data so therefore after the progam runs only the last line of data is displayed in the richtextbox. I need the lines to be displayed in a list but I don't know what code I can use to make sure the cursor moves to a new line before writting the data to the richtextbox.

I appreciate any help I can get with this problem.

Thanks in advance,

SubProf

Recommended Answers

All 2 Replies

Hi,
I think u not appending the text in Richtextbox rather u are assign a text
For Ex richText1.Text = someString; U can try richText1.Text += someString; or richText1.AppendText ( someString ); Example Code

string[] str = { "C#", "Programming", "language"};

    foreach (string s in str)
    {
        //richTextBox1.Text += s;
        //or
        richTextBox1.AppendText(s);
    }

Thank you for your help selvaganapathy - the code you suggested worked.

Thanks again,

SubProf

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.