Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
Posted

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,

 

'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=-

Whatever thy hand findest to do, do it with all thy heart - Jesus
  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...