getting the name of an event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EvilProject
    New Member
    • Nov 2007
    • 16

    getting the name of an event

    If I have, let say, 3 event handlers,all pointing to the same method.
    is there a way to find out which on invoked the method from within the method?

    for example:
    i have 3 event handlers

    Code:
    Grid1.MouseMove += new EventHandler(bla)
    Grid1.MouseDown += new EventHandler(bla)
    Grid1.MouseUp += new EventHandler(bla)
    
    private void bla(object sender,EventArgs e)
    {
      // what should I write here to find out if it was a mouse move , a mouse down 
      // or a mouse up event.
    }
    thanks in advance
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Wouldn't you be better off using the correct event handlers for those events (the MouseEvents)?

    Comment

    • EvilProject
      New Member
      • Nov 2007
      • 16

      #3
      Originally posted by Plater
      Wouldn't you be better off using the correct event handlers for those events (the MouseEvents)?
      i used those just for the example, it doesnt really matter as long as the question is clear. what i want is a way to find out which one called the method

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Well I am not sure you can tell *scratches head*
        I mean if you used the correct eventhandlers, they would all be different, but if you want to use a generic event handler, i'm not sure.
        If they came from different controls the sender object could be used, but if it's the same control I'm not sure how.
        Maybe something about the "currently executing assembly" could tell you?
        Or if you were keeping track of the windows messages in the pump?

        Comment

        Working...