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
Solved

Tab control fire event vb.net 2008

Posted on 2009-05-04
5
582 Views
Last Modified: 2013-11-26
I have a tab control with few tab. how to fire an event when use click on the tab. I need some code in vb.net 2008
0
Comment
Question by:aarontham
5 Comments
 
LVL 1

Expert Comment

by:chuckdsc
ID: 24296852
aarontham,

are  you looking at executing any function when a user changes the tab or when a user clicks on the tab ?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24298896
You can use SelectedIndexChanged event in the TabControl
    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
 
        Debug.WriteLine(Me.TabControl1.SelectedTab.Name.ToString)
 
    End Sub

Open in new window

0
 

Author Comment

by:aarontham
ID: 24301105
Hi jpaulino,

i just need to populate the datagribview in tab1 when user click on tab1. same with tab2 and tab3.
is that advice to unbound that datagriview in tab1 when user click on tab2?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24301158
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
 
For Each ctrl As Control In TabControl1.SelectedTab.Controls
            If TypeOf ctrl Is datagridview Then
                Dim dgView as datagridview = ctrl
               
                'Do your staff here...

                Exit For
            End If
        Next

End Sub

post if you have questions...
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 24302009
You can check what tab is selected and then fill the appropriate datagridview.
I think you have different datasources for each datagridview, right ?

    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        Select Case Me.TabControl1.SelectedIndex
 
            Case 0 ' First tab
                Me.DataGridView1.DataSource = ...
            Case 1 ' Second tab
                Me.DataGridView2.DataSource = ...
            Case 2 ' Third tab
                Me.DataGridView3.DataSource = ...
        End Select
    End Sub

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 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