Multiline textbox autoscrol & Form redraw Q

Wespen

Newcomer
Joined
Jan 13, 2003
Messages
10
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
 
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.
 
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)
 
Try adding text like this:

Visual Basic:
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.
 
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 :)
 
Back
Top