How to set focus on control within tabcontrol when tab changes?

I have a tabcontrol with three tabs.

First tab has several controls.
Second tab has only one control.
And the last tab has several controls.

How do I set the focus to a control within a tab when the tab page changes?

Code such as the following did not work for me.

If Me.TabControl1.SelectedIndex = myTabPageTreatment Then
End If

Thanks for all help!!!


  • i dont know if this is what u want..but ill try my luck nway.. :)'s quite easy to set focus on any control...
    u just open up the properties window for that particular contol...look for an option of TabIndex..then change the tab index...
    set it to 0 for the control that u want to focus immediately as the tab loads and 1 for the next..2..3..and it goes on...
    go to the next tab and do the same thing for the controls on it...

    hope it helps..

  • Thanks Raina

    As it turns out I know about this and already have the tab sequence set as desired. I don't want to change the tab sequence (too many tabs with too many controls). I could not manually manage that. What I am looking for is: say you have a tab control with three tabs and each tab has 15 controls, plus labels , etc. When tab 1 is clicked, I want to be able to set the focus to a certain control within the tab. Ditto for tab 2 and tab 3.

    I appreciate your being gracious and taking the time to help. Many blessings to you.


  • Hello,
    You can do it like this.

    this way you can programmatically change the table
    E.g. you are clicking a button and changes the tab control.
    Hope this works, as for me , it did!

  • Suppose If you have One TabControl(Tabcontrol1) and three Tab pages

    if you are in Tabpage1 and if you want to goto Tabpage3


    TabControl1.SelectedTab = TabPage1

    txbVisitTreatment.Focus() ' If u want to focus to any control
  • Hi,
    The TabControl is a container control that allows you to display multiple tab on a single form and it allowed switching between the tabs....
    for more information check this link...
    [link= in VB.Net] in VB.Net[/link]

    thanks !!!
  • This post has been deleted.
  • This post has been deleted.
  • This post has been deleted.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!