Set Focus to textbox on tab control

H

Henry Jones

VS 2005

On a form I have a tabcontrol with 5 tabs. Each tab has three textboxes on
it. When I click on each tab, I would like to have the focus set to the
first textbox.

On the tabenter event for each tab, I put a textbox1.focus but the textbox
doesn't contain the cursor.

How can I do this?
 
T

tomb

Try putting it in the click event of the tabcontrol. Just verify the
index of the selected tab, then focus on the appropriate textbox.

Tom
 
H

Henry Jones

I wanted the textbox to have the focus when the tab appears in front. I
have already clicked on the tab label at the top and when I put the focus in
the click event on the tab, your suggestion works, but I might as well have
clicked in the textbox!

I would like to have focus on the textbox when the tab appears. Any
suggestions?

Thanks

H
 
G

gene kelley

I wanted the textbox to have the focus when the tab appears in front. I
have already clicked on the tab label at the top and when I put the focus in
the click event on the tab, your suggestion works, but I might as well have
clicked in the textbox!

I would like to have focus on the textbox when the tab appears. Any
suggestions?

Thanks

H

You would need to get the child index of the first textbox on each page before you
can set it's focus:

With Me.TabControl1.SelectedTab
.Controls(.Controls.GetChildIndex(Me.SomeTextBox)).Focus()
End With

In the TabControl SelectedIndexChanged event, identify the selected tab and then
setup a Select Case statement for the 5 tabs to specify which patricular textbox
reference goes into the above code.

Gene
 

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