Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted
I'm not sure I understand what you mean, it sounds to me like you want the TabIndexChanged event of a TabControl?
Anybody looking for a graduate programmer (Midlands, England)?
Posted

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...

// 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
}

Anybody looking for a graduate programmer (Midlands, England)?
Posted

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.

Posted

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.

 

this.tabControl1.add_TabIndexChanged( new System.EventHandler(this.tabControl1_TabIndexChanged) );
private void tabControl1_TabIndexChanged (Object sender, System.EventArgs e)
{

}

Anybody looking for a graduate programmer (Midlands, England)?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...