AlteredImage Posted May 16, 2005 Posted May 16, 2005 (edited) 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. Edited May 16, 2005 by AlteredImage Quote
Administrators PlausiblyDamp Posted May 16, 2005 Administrators Posted May 16, 2005 Any chance you could post the relevant code? It could be an issue with the threading (threads and GUI code can be a real pain to deal with). Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Wile Posted May 16, 2005 Posted May 16, 2005 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. Quote Nothing is as illusive as 'the last bug'.
AlteredImage Posted May 16, 2005 Author Posted May 16, 2005 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. ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.