I have a number of Inherited User Controls, for each User Control I sometimes have overridden event Handlers for the Buttons on the Control. (To allow for Child specific behaviours to occur)
Is there a way of viewing all the Event Handlers associated with a particular component?
The problem being that on one of the Buttons, the event handler wass being called twice. I believe this was due to the fact that I had assigned the Click Event Handler twice, once in the parent and once in the child User Control. I remove the assignment in the child control and now nothing happens when I click the button (within the VS2008 designer)!
Any and all help will be gratefully received!
EDIT
The reason nothing happened is down to a verion control issue .... the child's overidden event handler was incorrect!
But the main point still remains... Im not the only contributer to the codebase, and If I need to see which events are attributed to a component I cant explicitly at the moment. Especially with regards to Timers as we dynamically add and remove events that need t obe 'synchronised' to a single timer. It would be good to see which Events are tagged onto the Tick event?!
-
The only way to view all event handlers on a component (that I know of) is to write code to do it for you, probably using Reflection.
The VS 2008 designer won't do this for you; despite the fact that most events on Controls are multicast, the designer only supports assigning a single handler per event. If you're doing anything more complex than this, you'll only get accurate results if you actually debug your program.
-
Could maybe try look at the source code to see if it is assigned twice? Either in the
.csfile or in the.designer.csfile. -
You could do a text search on entire solution or current project source code based on what you're looking for.
Search for example: "controlName.EventName +=". You'll directly see what has subscribed to this control event. -
Using Resharper, I do this using Shift-F12, which shows a tree view of all usages (including usages via an interface). Without Resharper, it is probably simplest to use text search as Tyalis suggests.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.