By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,259 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,259 IT Pros & Developers. It's quick & easy.

Get event which call method

P: n/a
Hi,

I need to get event name which call method. How do I do this? For
example - I have button with subscribed Click event and e.g. GotFocus.
For both this events I have the same method which consume this event
(let's say eventOccured). In eventOccured method I need to get
information which event occured.

E.g. when I click on button I get in eventOccured that was fired by
Click event.

Is it possible to get this info? How to do this?

Best regards,
Klaudiusz
Jul 4 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Well, a grungy way would be to walk the stack, but I'd just forward the
event-handlers to the inner method along with the extra info:

foo.Click += delegate {EventOccurred("Click");};
foo.GotFocus += delegate {EventOccurred("GotFocus");};

Where those strings could just as easily be an enum, and we could
optionally pass in the sender/args etc...

Marc
Jul 4 '08 #2

P: n/a
On 4 Lip, 14:56, Marc Gravell <marc.grav...@gmail.comwrote:
Well, a grungy way would be to walk the stack, but I'd just forward theevent-handlers to the innermethodalong with the extra info:

foo.Click += delegate {EventOccurred("Click");};
foo.GotFocus += delegate {EventOccurred("GotFocus");};

Where those strings could just as easily be an enum, and we could
optionally pass in the sender/args etc...

Marc
Hi,

Thanks. It works perfect.

Klaudiusz
Jul 4 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.