|
-
May 12th, 2009, 06:58 AM
#1
Thread Starter
Junior Member
Scroll down in a textbox
I have a textbox which is inside the second tab of a tab container.
When I load the form, I load a file into that textbox. Is there any way to send the scrollbar at the bottom of the text box. I want to show only end part of the file.
I have tried this, but it does not work (maybe because is inside a tab container?):
Code:
Textbox1.SelectionStart = Textbox1.TextLength
Textbox1.ScrollToCaret()
thanks
-
May 12th, 2009, 11:05 AM
#2
Lively Member
Re: Scroll down in a textbox
Use SelectionLength instead of start
Code:
TextBox1.SelectionLength = TextBox1.Text.Length
TextBox1.ScrollToCaret()
-
May 12th, 2009, 05:05 PM
#3
Thread Starter
Junior Member
Re: Scroll down in a textbox
 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.
-
May 12th, 2009, 05:13 PM
#4
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.
-
May 12th, 2009, 05:21 PM
#5
Thread Starter
Junior Member
Re: Scroll down in a textbox
 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
-
May 12th, 2009, 05:46 PM
#6
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!)
Last edited by keystone_paul; May 12th, 2009 at 05:51 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|