|
-
Jul 2nd, 2007, 10:15 AM
#1
Thread Starter
Registered User
[RESOLVED] [2005] What events is my procedure handling?
Hi all,
I am studying up on Events and have a question I couldn't find an answer to.
Let's say I create a number of controls at runtime and use AddHandler to connect the control's Click event to myProcedure at some point. Is there a way to go back later in the code and see what events my procedure is handling? i.e. If myProcedure is handling TextBox1.Click then do something.
I'm not sure why or if I would ever even need to do this but the question popped into my head and I'm just curious.
Thanks for any insight.
-
Jul 2nd, 2007, 10:54 AM
#2
Re: [2005] What events is my procedure handling?
Nothing obvious in the EventInfo type...hmm - probably not possible.
-
Jul 2nd, 2007, 10:59 AM
#3
Re: [2005] What events is my procedure handling?
You could probably have the event handler pop up a message box or something and you could try each control to see which is triggering it.
-
Jul 2nd, 2007, 11:24 AM
#4
Fanatic Member
-
Jul 2nd, 2007, 01:17 PM
#5
Thread Starter
Registered User
Re: [2005] What events is my procedure handling?
Thanks for the responses.
I was wondering if there was some built-in way to do this. Going to leave this unresolved for a bit just in case anybody else wants to chime in.
-
Jul 3rd, 2007, 04:26 PM
#6
Re: [RESOLVED] [2005] What events is my procedure handling?
Not got it working as yet, but MulticastDelegate.GetInvocationList seems to be the keystone to this puzzle...
-
Jul 3rd, 2007, 06:27 PM
#7
Frenzied Member
Re: [RESOLVED] [2005] What events is my procedure handling?
If you figure it out let us know.
However a less elegant approach might be to store a reference to the Delegate in the tag of the object as it's being created.
Then later if you want to know which Delegates are pointing to the Sub, just iterate through all of the controls tags, check each tag's delegate Method (i.e. DelegateName.Method) to see if it's pointing to the Sub you are interested in.
but I think this will only work for instance methods that are targets of a delegate (but it might be worth a try anyway).
That might also lead to issues of not removing all delegate references when you think you are later on (because some might still be in the tags).
Last edited by FourBlades; Jul 3rd, 2007 at 06:31 PM.
-
Jul 5th, 2007, 06:53 AM
#8
Fanatic Member
Re: [RESOLVED] [2005] What events is my procedure handling?
Another option along the lines of what fourblades proposes would be to create your own control, have it inherit the textbox and add a delegate property to it. Not sure of what all the details would be but I do not believe it would be too involved...../shrug
Good Luck,
D
Platforms of choice: Visual Studio 2005/2008 Professional : Visual Studio 2010 Enterprise : PHP - Notepad++/WAMP
Please Rate If I helped you. 
Please remember to mark threads as closed if your issue has been resolved.
Reserved Words in Access | Connection Strings
-
Jul 5th, 2007, 08:10 AM
#9
Thread Starter
Registered User
Re: [RESOLVED] [2005] What events is my procedure handling?
Thanks for the additional replies. I haven't played with anything yet, but when I do decide that I need to do something like this, I'm coming directly back to this thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|