Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scrolling to end of multiline textbox 1

Status
Not open for further replies.

JohnVogel

Programmer
Apr 19, 1999
117
US
I have a multi-line textbox control on my form. I am programmatically entering text into the text box with Textbox1.Text = "this text" & vbNewLine & "next line" etc.

I have the Verticle Scroll bars set on the textbox.

What I would like to know is how to automaticall scroll the text to the bottom of the textbox as new text is added.



-+{John Vogel}+-


 
First replace
Textbox1.Text = "this text" & vbNewLine & "next line" etc.
with
Textbox.Append(vbNewLine & "next line")

or
Textbox.Append(vbNewLine)
Textbox.Append("next line")

Then
Textbox.SelectionStart = TextBox.TextLength


- free online Compare/Diff of snippets
 
Ooops
I thought that
Textbox1.Text = "this text" & vbNewLine & "next line" etc.
was
Textbox1.Text = Textbox1.Text & vbNewLine & "next line"

Anyway, keep Append in mind and Textbox1.TextLength not
Textbox1.Text.Length


- free online Compare/Diff of snippets
 
Thanks, John. You must have read my mind, too, about the textbox1.Text = Textbox1.Text & vbNewLine (etc.) Because I was appending and I didn't even know there was a TextBox1.Append... Well, that's much easier. Thanks also for the answer to my post ;) Textbox.SelectionStart = TextBox.TextLength was just what I needed.

Take care!

-+{John Vogel}+-


 
oops, I spoke to soon. It sounded right, though, but it's still not scrolling to the end of the text.

-+{John Vogel}+-


 
Oops

Textbox must have focus.

"Note You can programmatically move the caret within the text box by setting the SelectionStart to the position within the text box where you want the caret to move to and set the SelectionLength property to a value of zero (0). The text box must have focus in order for the caret to be moved."

- free online Compare/Diff of snippets
 
Thanks, I should have known about that focus, I learned that in VB6 :-D

Thanks again for the tip, it's working beautifully now.

-+{John Vogel}+-


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top