TextBox Scroll Prevention if not at bottom

WadeV1589
05-12-2006, 09:55 AM
I'm making a program that has a text box that scrolls to the bottom whenever new text is added to it (imagine a chat app, new text is added with a date stamp at the bottom). However I want users to be able to scroll up the text box to read stuff that's off screen at which point new text should not make the text box scroll until they manually scroll back down to the bottom again (or hit Ctrl+End to go to the end of the textbox)

Any help on how to do this would be appreciated.

jwakeman
05-12-2006, 01:59 PM
can you post the code you use to make the textbox scroll to the bottom when text is added?

WadeV1589
05-12-2006, 02:04 PM
.AppendText("text") makes it scroll to the bottom after new text added.
.Text &= makes it scroll to the top after new text added.

jwakeman
05-13-2006, 10:04 AM
I know this probably isn't extremely helpful but I found the following code found here http://www.freevbcode.com/ShowCode.asp?ID=153 which basically is another way of doing what you are already doing.....i was thinking maybe you could figure out how to tweak this one to get your desired behavior.
Const MAXCHARS = 10000
'Don't go over 50,000 (Hidden vbCrLf's count as 2 characters)

Private Sub Post(tbxEditBox As TextBox, sNewText As String)
With tbxEditBox
If Len(sNewText) + Len(.Text) > MAXCHARS Then
'Scroll some text off the top to make more room
.Text = Mid$(.Text, InStr(100 + Len(sNewText), _
.Text, vbCrLf) + 2)
End If
.SelectionStart = Len(.Text)
.SelectedText = sNewText
End With
End Sub

Also check out this link http://www.codeproject.com/vb/net/VbNetScrolling.asp

Seems pretty in depth with the API calls and everything but you could probably hack something together with it, depends how much it is worth to you.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum