Solved

How To Determine Which TabPage Was Clicked on the Tab Control

Posted on 2006-11-29
4
280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Hillwaaa
Hillwaaa earned 50 total points
ID: 18041942
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
ID: 18041945
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
ID: 18041997
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
ID: 18046895
Thanks all for the great help!  I love Experts-Exchange!

Cheers,
Denise
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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