Scroll to bottom of textbox

  • Thread starter Thread starter Rob T
  • Start date Start date
R

Rob T

I have a multiline textbox that shows a log. When I keep adding items to
the textbox, I would like it to autoscroll to the bottom. I thought moving
the cursor to the end would do it like (ie.
boxHistory.SelectionStart=999999), which does move the cursor, but doesn't
scroll.

How would I do this? Thanks.

-Rob T.
 
I have a multiline textbox that shows a log. When I keep adding items to
the textbox, I would like it to autoscroll to the bottom. I thought moving
the cursor to the end would do it like (ie.
boxHistory.SelectionStart=999999), which does move the cursor, but doesn't
scroll.

How would I do this? Thanks.

Set SelectionStart to the length of the textbox. Then call the
ScrollToCaret() method.
 
* "Rob T said:
Found it: boxHistory.ScrollToCaret() ;-)

For RichTextBoxes you will have to set the focus to the control (by
calling its 'Focus' method) before calling this method.
 
Back
Top