Tab control in vb 2005

Posted on 2007-08-11
Last Modified: 2013-11-26
I have a tab control on a form with 6 tabs. I would like to disable certain buttons on the form that are not on the tab if the focus changes to a different tabpage in the collection. I have tried the code below, but it doesn't work.

Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
        If TabPage2.Focused Then
            btnFirst.Enabled = False
        End If

    End Sub
Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
        If CBool(CInt(TabPage1.Focused)) Then
            btnFirst.Enabled = False
        End If

    End Sub
Question by:mindserve
    1 Comment
    LVL 46

    Accepted Solution

    Hi mindserve,

    Handle the parent TabControl's Click event....

        Private Sub TabControl1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.Click
            If TabControl1.SelectedTab Is TabPage2 Then
                btnFirst.Enabled = False
            End If
        End Sub



    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video discusses moving either the default database or any database to a new volume.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now