Wespen Posted January 15, 2003 Posted January 15, 2003 Hi all, How can I autoscroll multiline textbox when I have 2many lines? I tried ScrollToCaret but since there is no focus on control and text is added trough code it won�t work. Another thing, I have some demanding code on Button click handler and when I tab the form down and back up controls don't show (I know I have to redraw whole form to render stuff on it again but how?) Should I rather use threading instead? Thanks Igor Quote
*Gurus* divil Posted January 15, 2003 *Gurus* Posted January 15, 2003 How are you adding text to the textbox? I think if you use AppendText, it should scroll with the text as it's added. It does in my experience anyway. As for your other question, it depends on what you're doing really. It does sound as if you might have a good use for threading there. It may be simple enough to stick an Application.DoEvents() in your intensive loop. If you don't find a solution, let us know what your loop is doing and for how long, and we'll be able to advise better. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Wespen Posted January 15, 2003 Author Posted January 15, 2003 I'm adding text - tb.text += "some text"+Enviroment.newline (can I go to next line different?) Loop is dloading allmost entire site (like 1000 pages, and parse HTML) TBox is for status display (ie. Connected, Dloading page 1 of xxx an so on) Quote
*Gurus* divil Posted January 15, 2003 *Gurus* Posted January 15, 2003 Try adding text like this: txtDebug.SelectionStart = txtDebug.Text.Length txtDebug.SelectedText = strText & Environment.NewLine And you'll find it scrolls to the bottom automatically as new text is added. The method you are presently using is not very efficient at all, you are resetting the whole text every time you add to it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Anon Posted February 26, 2009 Posted February 26, 2009 AppendText does not (in my case) scroll down, maybe if you got just one textbox..(?). Anyway, I solved it by shifting focus: this->txtOutput->Focus(); // the box who needs to be scrolled down this->txtInput->Focus(); // the box to which initially had the focus Just realized it's from 2003... But I found this thread, so hope it'll be helpfull for anyone else. (btw, registerd to post this just now :) 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.