closet geek Posted April 7, 2006 Posted April 7, 2006 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. Quote
Cags Posted April 7, 2006 Posted April 7, 2006 I'm not sure I understand what you mean, it sounds to me like you want the TabIndexChanged event of a TabControl? Quote Anybody looking for a graduate programmer (Midlands, England)?
closet geek Posted April 7, 2006 Author Posted April 7, 2006 Sounds about right, but how do I create a function that is always listening for that event? :) Quote
Cags Posted April 7, 2006 Posted April 7, 2006 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 } Quote Anybody looking for a graduate programmer (Midlands, England)?
closet geek Posted April 11, 2006 Author Posted April 11, 2006 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. Quote
Cags Posted April 11, 2006 Posted April 11, 2006 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) { } Quote Anybody looking for a graduate programmer (Midlands, England)?
Administrators PlausiblyDamp Posted April 11, 2006 Administrators Posted April 11, 2006 Not sure how these are done in J# but those are events not methods. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.