Solved

Tab control fire event vb.net 2008

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

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

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