tabclicked event handler

closet geek

Newcomer
Joined
Apr 2, 2006
Messages
21
Hi,

I had a look but couldn't find any thread which matched. I want to know how to implement a method that listens for a change of tab (e.g. someone clicks from one tab to a different tab) and for that click to trigger an event.

J# would be ideal, C# is fine, VB probably wont help me see what to do I'm afraid :p

Thanks.
 
You don't create a function that listens for that advent exactly. You just attach a method to that event. I guess they could be defined as the same thing. To attach an event in c# you would do...
C#:
// this attaches a method to the event handler
tabControl1.TabIndexChanged += new EventHandler(tabControl1_TabIndexChanged);

// this is the method used by the event handler
private void tabControl1_TabIndexChanged(object sender, EventArgs e)
{
    // perform action here
}
 
Thank you once again for helping out, but I'm struggling to implement your suggestion in j#.

There is no TabIndexChanged or IndexChanged method(?) for tabControl1 - I tried using Focus() instead as that would produce the same results (at a guess).

However it just comes back with the error "Identifier Expected" and I'm a bit stumped.

Sorry if these questions are a bit dumb.
 
It's worth noting that if the control is on your page at design time you can attach events using Visual Studio. Select the control, then in the Properties bar at the side click the small yellow lightning bolt to see a list of events.

I had a quick look and it would appear the code you require is as follows.

Code:
this.tabControl1.add_TabIndexChanged( new System.EventHandler(this.tabControl1_TabIndexChanged) );
private void tabControl1_TabIndexChanged (Object sender, System.EventArgs e)
{
	
}
 
Back
Top