Omar Bahir
Omar Bahir

Reputation: 1267

Scroll richtextbox in c#.net

I'm looking for C#.net code to scroll a richtextbox programmatically, I have searched about it but I found some examples of VB.Net but don't know how to use them. any help would be highly appreciated. Thanks in Advance :)

Upvotes: 1

Views: 918

Answers (1)

odinmillion
odinmillion

Reputation: 639

If I properly understand, you want to scroll richtextbox to the bottom after new lines were added to this control. Just add this code to method that runs each time you add some new data:

private void AddText(string text)
{
    richTextBox1.AppendText(text + Environment.NewLine);
    richTextBox1.SelectionStart = richTextBox1.Text.Length;
    richTextBox1.ScrollToCaret();
}

Upvotes: 2

Related Questions