Tab Control [vb 2005]

Momo

Member
Joined
May 30, 2006
Messages
21
Programming Experience
Beginner
Currently, I work with tab control. As I found that if let say I put a "Messagebox.show("Click Me!")" at Click of a particular tab pages in the tab control, it doesnt work. Anybody here know how the tab pages onclick function can work properly. Tq.
 
Note that the tabs at the top are NOT part of the TabPages. The area where you can place controls is the TabPage. The tabs at the top are part of the TabControl. You would need to handle the Click event of the appropriate object to get a response. Try adding a TabControl to an empty form and then add this code:
VB.NET:
Private Sub TabControl1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.Click
    MessageBox.Show("You just clicked the TabControl.")
End Sub

Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
    MessageBox.Show("You just clicked TabPage1.")
End Sub

Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click
    MessageBox.Show("You just clicked TabPage2.")
End Sub
Now try clicking in various places and see what messages you get.
 
Thanks. Yups, actually what i want to achieve is to click on the top of Tab (means apart of the tabcontrol) not the tab pages to display the messsage. Is that's any idea to achive this?
 
It doesn't really matter if and when the user clicks on a tab. Only when a TabPage is selected, which you will be notified about by the SelectedIndexChanged event of the TabControl. This event will be raised whenever a different TabPage is selected either in code or by the user clicking or using the arrow keys.
 
Back
Top