Re: Scroll down in a textbox
Use SelectionLength instead of start
Code:
TextBox1.SelectionLength = TextBox1.Text.Length
TextBox1.ScrollToCaret()
Re: Scroll down in a textbox
Quote:
Originally Posted by
Rykler
Use SelectionLength instead of start
Code:
TextBox1.SelectionLength = TextBox1.Text.Length
TextBox1.ScrollToCaret()
I have tested it and it did not work. What I see is than as it is place on a secondary tab, it did not receive focus. If I place the textbox outside tab container I see selection made, but it does not scroll to end.
Re: Scroll down in a textbox
When you say the text box is on the second tab of a tab container - presumably this tab is the active tab? Or are you saying you load the form and populate the text box and then set the selection all while the tab containing the textbox is inactive, and when you switch to the 2nd tab the selection is reset?
I just want to be sure I understand the sequence of events you are going through.
Re: Scroll down in a textbox
Quote:
Originally Posted by
keystone_paul
When you say the text box is on the second tab of a tab container - presumably this tab is the active tab? Or are you saying you load the form and populate the text box and then set the selection all while the tab containing the textbox is inactive, and when you switch to the 2nd tab the selection is reset?
I just want to be sure I understand the sequence of events you are going through.
No, the tab which has the textbox is the second one and is not active/visible. The active tab is the first one.
When I load the form, I load the text in the textbox, but as it is not visible I can not get it to scroll down to the end. I want that when clicking second tab, the textbox automaticaly scroll to the end
Re: Scroll down in a textbox
The problem seems to be finding the right event to trap. If I set up a similar form and put this code :
Code:
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
If CType(sender, TabControl).SelectedIndex = 1 Then
TextBox1.Select(TextBox1.TextLength, 1)
TextBox1.ScrollToCaret()
TextBox1.Focus()
End If
End Sub
That seems to work (assuming of course that the textbox isn't empty!)