Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Dear,

Is there any global way to capture any event fired in my application.

Means if a button1 was clicked in the form1 i want for example to alert(messageBox.show) the following: button1 - form1 - button1_Clicked;

the main thing is that i want a global function that will allow not to put the code in every event

Thanks in advance

Posted
Updated 25-Nov-09 19:23pm
v2

Probably, this article is what you need:

http://www.codeproject.com/KB/cs/eventtracingviareflection.aspx

 
Share this answer
 
well didn't help, as much as i'm concerned
 
Share this answer
 
I just browsed through the article. The Tracer class (not sure if this is the correct name) seems to *know* what all events have occured in the form. You need similar mechanism. Although you need to do some activities once you know some event has occured. If you can create some thing similar in your application and just tweak a bit as per your needs, I guess you will be done.
 
Share this answer
 

If you don't mind writing a single line of code in each event handler.

I guess you could create a custom event with a custom event arguments class containing an enumerator for all your supported events along with the original event arguments, and then fire this event within each of your current handlers. But this sounds like a lot of trouble. I'd rather just place a code region around all my eventhandlers if I wanted better grouping of logic. 

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900