I have a rich text box which serves as a log. The log automatically scrolls itself down when a new message is appended, which is good. The only problem is when the user wants to view something in the log from before; if a new message is appended, the box automatically scrolls all the way down and prevents the user from seeing anything. I would like to be able to check if the rich text box is scrolled all the way down, and if it isn't not scroll down.
Currently I can get the scroll position in the virtual text space (SendMessage with EM_GETSCROLLPOS). I can also get scroll bar info with GetScrollBarInfo pinvoke. But how do I figure out what the bottom of the virtual text space is?
Thanks!
Use a vScrollBar
control for your RichTextBox
and handle its Scroll event
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
if (e.Type == ScrollEventType.Last)
{
//scrollbar is all the way down
}
else
{
//user has scrolled up
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With