Textbox Scroll Issue

M

Materialised

Ok, I have trawled google groups for the last hour, and have found no >net
work around to my issue.

Basically my problem is a simple one. I have a multiline textbox and a
command button. When the button is pressed text is appended to the text box.
I would like the textbox to automatically scroll to the end of the data to
be added.
In VB6 I would do it with:

TextBox1.SelStart = Len(TextBox1.Text)

However I can't seem to find a VB.net (2005) workaround.

I have tried:

Textbox1.Focus()
Textbox1.SelectionStart = TextBox1.TextLength

However that didn't work.
If anyone could help me out I would be thankful

Regards.
 
P

Peter Proost

Hi, you nee this:

TextBox1.SelectionStart = TextBox1.TextLength
TextBox1.ScrollToCaret()
TextBox1.Focus()

Hth Greetz Peter
 
M

Materialised

Thanks for that Peter.
Peter Proost said:
Hi, you nee this:

TextBox1.SelectionStart = TextBox1.TextLength
TextBox1.ScrollToCaret()
TextBox1.Focus()

Hth Greetz Peter
 
H

Herfried K. Wagner [MVP]

Materialised said:
Basically my problem is a simple one. I have a multiline textbox and a
command button. When the button is pressed text is appended to the text
box.
I would like the textbox to automatically scroll to the end of the data to
be added.
In VB6 I would do it with:

TextBox1.SelStart = Len(TextBox1.Text)

However I can't seem to find a VB.net (2005) workaround.

Adding a line to a richtextbox control and scrolling it into view
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=richtextboxscrolltobottom&lang=en>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top