Pete's Windows, Office, VB & SQL Blog

Problems I have solved (or not) and good ideas I've found

Archive for November 24th, 2009

How to scroll a textbox programatically as data is added

with one comment

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.

Written by fisherpeter

2009 November 24 at 17:17

Posted in VB express 2005

Tagged with