Solved

Adding text to a textbox and move down along the scrollbar

Posted on 2007-11-25
8
314 Views
Last Modified: 2013-11-26
Hi,

I have a timer which add some text (information) to a textbox, and since the textbox is small, I would like it to automatically scroll the textbox down as text are being added. Is it possible?
0
Comment
Question by:Sharalynn
  • 5
  • 3
8 Comments
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 500 total points
ID: 20346582
You can do this to your multi-line textbox:

TextBox1.AppendText("my text")
TextBox1.ScrollToCaret()
0
 

Author Comment

by:Sharalynn
ID: 20349173
Your code works, but however if I used:

TextBox1.Text &= "asfddf" & vbCrLf,

it will not focus on the textbox, and the caret will always be at the 0 position with text going down and down and the scrollbar getting longer and longer.. Any idea on how to solve that? Otherwise your code works perfectly fine.

What is the difference between the 2 of them anyway?
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 20349423
Hi Sharalynn,

That method causes textbox to loose the focus. To ScrollToCaret work you need to have focus and for that you will need to do this:

        TextBox1.Text &= "asfddf" & vbCrLf
        Dim txtLenght As Integer = Len(TextBox1.Text)
        TextBox1.Select(txtLenght, txtLenght)
        TextBox1.ScrollToCaret()

jpaulino
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 500 total points
ID: 20349429
Just one more thing:

Dim txtLenght As Integer = Len(TextBox1.Text)
TextBox1.Select(txtLenght, txtLenght)

This will put the cursor in the last position on the textbox. If you use simply TextBox1.Select() will select all the text.
0
 

Author Comment

by:Sharalynn
ID: 20349677
Excellent, I understand it totally now. Thank you jpaulino!

But one thing, you said we need to focus it, but since we used Select to go to the end of the line always, does it auto focus for us?
0
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 500 total points
ID: 20351031
When you select the control in the last position you will focus him.

Any question more ?
0
 

Author Comment

by:Sharalynn
ID: 20351043
Nope, you have answered all completely, thanks lots!
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 20351131
Glad I could help!
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question