Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 451
  • Last Modified:

Scrolling back up to the Top of a Textbox control

Hi, I'm using VB.NET2010, WinForms. I have a Form with a textbox, where I append some text to the textbox after parsing an external text file. That part works well.

However, once all the text is appended, the scroll-bar is all the way down at the bottom of the file. I'd like to have the scroll bar move to the top of the file, so the user doesn't have to scroll back up manually to begin viewing the file.

I tried  ScrollToCarrot(), but I'm not sure how to set the target "Carrot."

How would I do that or is there a better way?

Thanks,
Fulano
0
Mr_Fulano
Asked:
Mr_Fulano
  • 2
  • 2
  • 2
  • +1
1 Solution
 
miketonnyCommented:
try set focus first then use scrolltocaret()

 
      TextBox1.Focus()
        TextBox1.ScrollToCaret()

Open in new window

0
 
miketonnyCommented:
also, if that doesn't work for you,
use TextBox1.SelectionStart
0
 
käµfm³d 👽Commented:
Try setting the SelectionStart:
this.textBox1.SelectionStart = 0;
this.textBox1.Focus();    // If necessary (e.g. user clicks button to scroll)

Open in new window

0
Independent Software Vendors: 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!

 
Carlos VillegasFull Stack .NET DeveloperCommented:
In this way
        TextBox1.SelectionStart = 0
        TextBox1.ScrollToCaret()

Open in new window

0
 
käµfm³d 👽Commented:
Heheh...

Of course, in VB, you'd use "Me", not "this"  : )
0
 
Mr_FulanoAuthor Commented:
Most accurate solution. It worked as is. Thanks
0
 
Carlos VillegasFull Stack .NET DeveloperCommented:
Thanks
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now