We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Scrolling back up to the Top of a Textbox control

Mr_Fulano
Mr_Fulano asked
on
Medium Priority
464 Views
Last Modified: 2012-06-27
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
Comment
Watch Question

try set focus first then use scrolltocaret()

 
      TextBox1.Focus()
        TextBox1.ScrollToCaret()

Open in new window

also, if that doesn't work for you,
use TextBox1.SelectionStart
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

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

Full Stack .NET Developer
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2015

Commented:
Heheh...

Of course, in VB, you'd use "Me", not "this"  : )

Author

Commented:
Most accurate solution. It worked as is. Thanks
Carlos VillegasFull Stack .NET Developer

Commented:
Thanks
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.