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
Mr_FulanoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.