Solved

Tab control fire event vb.net 2008

Posted on 2009-05-04
5
579 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

Highfive Gives IT Their Time Back

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
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…

762 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

19 Experts available now in Live!

Get 1:1 Help Now