Fire Event when the tab is clicked

ahbenshaut

Well-known member
Joined
Oct 29, 2004
Messages
62
Location
Alaska
Programming Experience
5-10
Greetings to all!
I have a form that has a tab control on it. I want to load information as soon as the tab is clicked, not when the user clicks inside the tab window. Any help is greatly appreciated.

thanks
 
Okay here goes...
I have a tabcontrol with 4 tabs on it on a form.
In 2 of the tabs, there is a datagrid.
When the tab is clicked, I want to populate the corresponding datagrid. So far I have only beeen able to populate the datagrid after the user selects the tab, then clicks somewhere in the tab form. I'd like to do away with the last click.

hope that helps
 
Well, it would be best if you send some code (i cannot go for guessing)

In meantime, this is how you invoke an event by clicking certain tab (i also attached the project to see that it does change intended event/s correctly)
VB.NET:
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] TabControl1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] TabControl1.SelectedIndexChanged
[/SIZE][SIZE=2][COLOR=#0000ff]If [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TabControl1.SelectedTab.Text = "Page1" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MessageBox.Show("the first one was selected")
[/SIZE][SIZE=2][COLOR=#0000ff]ElseIf [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TabControl1.SelectedTab.Text = "Page2" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]MessageBox.Show("the second one was selected")
[/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

Regards ;)
 

Attachments

  • SelectedTab.zip
    26 KB · Views: 33
Well, there really wasnt anything wrong with my code, it was just in the wrong place. I was trying to use the individual tabs instead of using the tabcontrol to figure out which tab was clicked...sigh...
 
Back
Top