Please help with stopping a multi-line textbox from scrolling back to the top.

AlteredImage

Newcomer
Joined
May 16, 2005
Messages
2
Stopping a multi-line textbox from scrolling back to the top after refresh???

I've got a problem that's really racking my brains here. Hoping someone can help me out. Ok, I've got a Multi-line textbox. I'm using a background thread to continously add new text to it (textbox.text = textbox.text + newtext). Everytime the new text gets added the textbox refreshes, causing the textbox to scroll back to the top. I don't want the textbox to scroll back to the top. I need it to stay whereever the user scrolls the text to.
Any ideas on this one at all? I've googled it to death and haven't come up with much at all.
 
Last edited:
Lets be the proverbial pain in the *** and point out that doing GUI stuff on the wrong thread can result in strange results, check with textbox.InvokeRequired. If it returns true you're not on the GUI thread and shouldnt even change properties of the control.

But since I can also be usefull, take a look at the TextBox.SelectionStart and SelectionLength properties. A selectionlength of 0, and a start that is the length of the total string displayed should do the trick.
 
Fixed...and better even. ;)

Just wanted to thank you guys for your thoughts on threading.
What I did to fix it was I just used the "append" method of the textbox!
This alowed me add text without having to completely redraw everything, thus preventing the textbox from snapping back to the top.

Duh... I Kick myself in the butt for being so dumb. :rolleyes:

Thanks again. ;)
 
Back
Top