Solved

How To Determine Which TabPage Was Clicked on the Tab Control

Posted on 2006-11-29
4
240 Views
Last Modified: 2012-05-05
Hi,

I'm using VS.NET 2005.  When the user makes a selection from the tab control, I would like to load a combo box with specific data based on which tab page was clicked.  How do I create a tab control click event to identify which tab page was selected?

Thanks,
Denise
0
Comment
Question by:DeniseGoodheart
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Hillwaaa
Hillwaaa earned 50 total points
Comment Utility
Hi DeniseGoodheart,

You could use something like this (note you'll have to add multiple TabPageX.Click subs):

    Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
        Me.loadComboBoxVals("TabPage1")
    End Sub

    Private Sub loadComboBoxVals(ByRef page As String)
        If (page = "TabPage1") Then
            ... load combobox values here for page 1
        ElseIf (page = "TabPage2") Then
            ... load combobox values here for page 2
        End If
    End Sub

Cheers,
Hillwaaa
0
 
LVL 39

Accepted Solution

by:
appari earned 450 total points
Comment Utility
try like this

Private Sub tabcontrol1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tabcontrol1.SelectedIndexChanged
        Try
            If Me.tabcontrol1.SelectedTab.Equals(Me.tabPage1) = True Then
            msgbox("Tab page1 selected")
            Else
            msgbox("Other Tab page selected")
            End If

        Catch ex As Exception
           
        Finally
           
        End Try
    End Sub
0
 
LVL 16

Expert Comment

by:Hillwaaa
Comment Utility
Ah yes - my solution uses the wrong event - use the tabcontrol.SelectedIndexChanged as appari says.  You can still pass things out to a sub to load the combobox values if you want to keep things neat, but that's up to you :)
0
 

Author Comment

by:DeniseGoodheart
Comment Utility
Thanks all for the great help!  I love Experts-Exchange!

Cheers,
Denise
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

10 Experts available now in Live!

Get 1:1 Help Now