ScrollToCaret()

ARC

Well-known member
Joined
Sep 9, 2006
Messages
63
Location
Minnesota
Programming Experience
Beginner
So I have timer events firing... which adds text to the bottom line (essentially) of the maintext.text --

The Me.maintext.ScrollToCaret() in the past has assured me that the textbox would scroll to the bottom before sending focus back to another textbox --

My problem though, is that it isnt scrolling down to the bottom. 1 of 3 things could be the problem.

1) I miss-spelled the ScrollToCaret() command
2) It doesnt work the same with RichText fields (previous uses were in regular text boxes)
3) This should work, the problem isnt here, it's nested somewhere else in my code.

If someone could varrify that it's not 1 and or 2, that would be awesome :)

VB.NET:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.inputtext.Text = ""
Me.maintext.Text = Me.maintext.Text + "Voice: Hello!" & ControlChars.NewLine
Me.maintext.Focus()
Me.maintext.ScrollToCaret()
Me.inputtext.Focus()
End Sub
 
Hmm... I still havnt figured it out. That code works when I use it in a regular text box. Is there something different to use when in a richTextbox?
 
I haven't ran the code, but where is Caret when you focus the control? If it's not where you want it to be you could place it by making a 0-length selection first.
 
0-length selection puts the caret at the end? I want it to be after the last line of text in the field. I guess for some reason I just assumed the caret stayed at the end of anything you send to it to write.
 
Yes, selection can be anywhere you want, but it must 0-length to no be visible. When you make a selection that's where the Caret will be.
 
Back
Top