I have a RichTextBox which I want to automatically scroll to the end of the text, when new text gets added.
Here is my code:
private void outputWindowTextChanged(object sender, EventArgs e) {
rtb_outputWindow.SelectionStart = rtb_outputWindow.Text.Length;
rtb_outputWindow.ScrollToCaret();
}
I manually add a bunch of text to the RichTextBox, like so:
updateOutputWindow("Lorem ipsum dolor sit amet, ..."); //These strings are really long
updateOutputWindow("Lorem ipsum dolor sit amet, ..."); //I shortened them for this question
Here is the result:
In the above screenshot you can just barely make out that there is actually more text underneath the edge. You can also look at the scroll bar on the right, and see that there's a little bit of space left underneath.
In the above screenshot I manually scrolled down to the bottom, using the scroll bar on the right; revealing the before hidden text.
Is there a way to make sure that the RichTextBox automatically gets scrolled to the very end, every time?