Archive for November 24th, 2009
How to scroll a textbox programatically as data is added
This should be easy, but after some experimentation it appears at least this sequence is required:
textbox1.Text = textbox1.Text & sLine & Environment.NewLine ‘ Add the data
textbox1.Focus() ‘ claim the focus
textbox1.SelectionStart = Len(textbox1.Text) – 1 ‘ set the Caret
textbox1.ScrollToCaret() ‘ move the view of the text box
textbox1.Refresh() ‘ display the view of the textbox.
This works while the application itself has focus.