Code to keep at the bottom of multiline textbox..

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I have a multiline textbox on my form and it is used for a chat and everytime it is recieveing the messages, its moving the scrollbar back to the top.. which isn't going to work good at all for a chat program.. so, I need the code that will keep the scrollbar as long as it will go so each time something new is recieved it will go down more.
 
I must agree, the scrollbar for the text box can be a pain. Anyways, you can use scrolltocaret, but you must make sure that your text box has focus, which shouldn't be a big deal, because its a chat program. I haven't tested it out, but I think this code should work out,

Code:
 'Give Your TextBox Focus
 TextBox1.Focus()
 'Append Your Text Here
 TextBox1.Text &= StrMessage
 'Insert The Caret At The End Of The TextBox
 TextBox1.SelectionStart = TextBox1.Text.Length
 'Scroll To The End
 TextBox1.ScrollToCaret()

-=Simcoder=-
 
Back
Top