How do I scroll a RichTextBox to the bottom?
Solution 1:
You could try setting the SelectionStart property to the length of the text and then call the ScrollToCaret method.
richTextBox.SelectionStart = richTextBox.Text.Length;
richTextBox.ScrollToCaret();
Solution 2:
The RichTextBox
will stay scrolled to the end if it has focus and you use AppendText
to add the information. If you set HideSelection
to false it will keep its selection when it loses focus and stay auto-scrolled.
I designed a Log Viewer GUI that used the method below. It used up to a full core keeping up. Getting rid of this code and setting HideSelection
to false got the CPU usage down to 1-2%.
//Don't use this!
richTextBox.AppendText(text);
richTextBox.ScrollToEnd();