Results 1 to 9 of 9

Thread: [RESOLVED] [2005] What events is my procedure handling?

  1. #1

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Resolved [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.

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: [2005] What events is my procedure handling?

    Nothing obvious in the EventInfo type...hmm - probably not possible.

  3. #3
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    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.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    Re: [2005] What events is my procedure handling?

    Not unless you comment its use inside the sub *HINT*HINT*. If you are creating controls on the fly then there is really no way unlike dragging a control onto a form and adding (or having it added for you) the "Handles textbox.click" to it.

    *sidenote* if you are creating controls on the fly then: Directcast(Sender, ObjectType) will be your BEST friend, because you can do different things all in one sub with various types of controls!! Of course you may have already known that and I just wasted my breath......

    Good Luck in your studies!!

    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

  5. #5

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    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.

  6. #6
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    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...

  7. #7
    Frenzied Member
    Join Date
    Aug 2006
    Posts
    1,051

    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.

  8. #8
    Fanatic Member
    Join Date
    Aug 2006
    Location
    In my head
    Posts
    913

    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

  9. #9

    Thread Starter
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    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
  •  



Click Here to Expand Forum to Full Width