I've been writing a program that calls batch files (which download some stuff). I've added a label that reports the download progress to the user. The program is going to allow for multiple downloads so at some point the Label will be full of text. When that happens, the text extends from the label and I can't see any of it. What I want is to have the label scroll to the newer line of text added in the label. In other words I want to always have the focus of the label text to be on the last written line. Can some1 post an example that can do this on a label ?
Asked
Active
Viewed 325 times
-1
-
I would suggest you use a listbox for this. Labels don't have the functionality to do what you are asking. The closest you can do is right-align the text so you always see the end, as opposed to the beginning. – Steve Jan 16 '15 at 19:50
-
Thnx for your input. What do you mean by "right-align" the text ? – Panagiotis Gianniotis Jan 16 '15 at 19:54
-
Click on the label. In the properties window find the property "Text Alignment", change it from top-left to ?-right. – Steve Jan 16 '15 at 20:00
-
I already have the text aligned to the Bottom Right. All it does is that the text starts from there and goes upward. When the text reaches the top, then it stops showing me the new lines. – Panagiotis Gianniotis Jan 16 '15 at 20:10
-
1Not sure why it doesn't work for you but the point is, don't use a label. – Steve Jan 16 '15 at 20:27
1 Answers
1
Similar to Steve's comment I would recommend using a multiline text box or RichText control for this purpose. You can set the control's ReadOnly
property to True, and the ScrollBars
property to Both.
When adding new text to this control, you can use the following code to ensure that it is visible to the user:
TextBox2.AppendText('New text')
TextBox2.SelectionStart = TextBox2.Text.Length
TextBox2.ScrollToCaret()

Dave Michener
- 1,058
- 11
- 30