Solved

Adding text to a textbox and move down along the scrollbar

Posted on 2007-11-25
8
319 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

734 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