Set focus on a tabpage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Wright

    Set focus on a tabpage

    I have the following routine I use to check for a certain tab page. I want to enable this tab page only on the tab control and set the focus. However, I cannot get the tab to set focus no matter what I do. Any suggestions?


    Public Sub SetTabs(ByVal TabID As String)

    For Each Ctrl As Control In Me.Controls

    If TypeOf Ctrl Is TabControl Then

    If Ctrl.HasChildre n Then

    For Each cCtrl As Control In Ctrl.Controls

    If TypeOf cCtrl Is TabPage Then

    If cCtrl.Name = TabID Then

    Ctrl.Enabled = True

    Ctrl.Visible = True

    cCtrl.Enabled = True

    cCtrl.Visible = True

    Me.ActiveContro l = cCtrl

    Else

    cCtrl.Enabled = False

    End If

    End If

    Next

    Else

    Ctrl.Enabled = True

    Ctrl.Visible = True

    Me.ActiveContro l = Ctrl

    End If

    End If

    Next

    End Sub

  • rowe_newsgroups

    #2
    Re: Set focus on a tabpage

    On Jun 19, 4:23 pm, "John Wright" <riley_wrig...@ hotmail.comwrot e:
    I have the following routine I use to check for a certain tab page. I want to enable this tab page only on the tab control and set the focus. However, I cannot get the tab to set focus no matter what I do. Any suggestions?
    >
    Public Sub SetTabs(ByVal TabID As String)
    >
    For Each Ctrl As Control In Me.Controls
    >
    If TypeOf Ctrl Is TabControl Then
    >
    If Ctrl.HasChildre n Then
    >
    For Each cCtrl As Control In Ctrl.Controls
    >
    If TypeOf cCtrl Is TabPage Then
    >
    If cCtrl.Name = TabID Then
    >
    Ctrl.Enabled = True
    >
    Ctrl.Visible = True
    >
    cCtrl.Enabled = True
    >
    cCtrl.Visible = True
    >
    Me.ActiveContro l = cCtrl
    >
    Else
    >
    cCtrl.Enabled = False
    >
    End If
    >
    End If
    >
    Next
    >
    Else
    >
    Ctrl.Enabled = True
    >
    Ctrl.Visible = True
    >
    Me.ActiveContro l = Ctrl
    >
    End If
    >
    End If
    >
    Next
    >
    End Sub
    You need to grab the tabpage object (or it's index) and then set
    either the tabcontrol's selectedtab or selectedindex property to show
    the tabpage.

    Thanks,

    Seth Rowe

    Comment

    • John Wright

      #3
      Re: Set focus on a tabpage

      Bingo. Thanks. I had to modify the code a little. I had to create a
      tabcontrol object and set it = to the ctrl. Once this was done, I could set
      the selectedtab to the tabpage I had. Thanks.

      John
      "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
      news:1182306652 .186206.236220@ w5g2000hsg.goog legroups.com...
      On Jun 19, 4:23 pm, "John Wright" <riley_wrig...@ hotmail.comwrot e:
      >I have the following routine I use to check for a certain tab page. I
      >want to enable this tab page only on the tab control and set the focus.
      >However, I cannot get the tab to set focus no matter what I do. Any
      >suggestions?
      >>
      >Public Sub SetTabs(ByVal TabID As String)
      >>
      > For Each Ctrl As Control In Me.Controls
      >>
      > If TypeOf Ctrl Is TabControl Then
      >>
      > If Ctrl.HasChildre n Then
      >>
      > For Each cCtrl As Control In Ctrl.Controls
      >>
      > If TypeOf cCtrl Is TabPage Then
      >>
      > If cCtrl.Name = TabID Then
      >>
      > Ctrl.Enabled = True
      >>
      > Ctrl.Visible = True
      >>
      > cCtrl.Enabled = True
      >>
      > cCtrl.Visible = True
      >>
      > Me.ActiveContro l = cCtrl
      >>
      > Else
      >>
      > cCtrl.Enabled = False
      >>
      > End If
      >>
      > End If
      >>
      > Next
      >>
      > Else
      >>
      > Ctrl.Enabled = True
      >>
      > Ctrl.Visible = True
      >>
      > Me.ActiveContro l = Ctrl
      >>
      > End If
      >>
      > End If
      >>
      >Next
      >>
      >End Sub
      >
      You need to grab the tabpage object (or it's index) and then set
      either the tabcontrol's selectedtab or selectedindex property to show
      the tabpage.
      >
      Thanks,
      >
      Seth Rowe
      >

      Comment

      Working...