Automatically Scroll RichTextBox To Bottom

Normally when you want a RichTextBox to automatically scroll to the bottom, whenever you add new lines to it, all you need to do is append the new lines with the AppendText() method.

myRichTextBox.AppendText("My new line of text");

However, it seems that the RichTextBox does not always scroll down immediately after calling this method. For instance you’re using a RichTextBox to display the progress of a long or time consuming process and the lines of text are appended to the RichTextBox quickly after each other; the RichTextBox might not scroll to the bottom until the entire process has been completed, or it will scroll only sometimes during the process.

In order to force the RichTextBox to scroll immediately to the bottom call the ScrollToCaret() method.

myRichTextBox.AppendText("My new line of text");
myRichTextBox.ScrollToCaret();

Leave a Reply

Your email address will not be published. Required fields are marked *

*