Solved

How To Determine Which TabPage Was Clicked on the Tab Control

Posted on 2006-11-29
4
270 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Generate Numbers in JQuery file 11 72
MailAddress in vb 4 36
Vb.net threads keep increasing 2 49
CHANGE FORM TEXT BEFORE IT SHOW TO USER 13 17
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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