Solved

Tab control fire event vb.net 2008

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

Containers and Docker for Everyone

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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