How can I get an actual EventHandler delegate instance from an event in VB.NET?

前端 未结 2 839
刺人心
刺人心 2020-12-20 15:51

In C#, I could do something like this:

EventHandler handler = this.SomeEvent;

...which would allow me to, for example, do:

         


        
相关标签:
2条回答
  • 2020-12-20 16:35
       Private Event MyEvent()
       Private delegates() As System.Delegate = MyEventEvent.GetInvocationList()
    

    undocumented, found here

    0 讨论(0)
  • 2020-12-20 16:41

    if you take a look at this How to Attach the Events of an Original Object to a Deep Copied Clone I have a code example on how to get the delegate for the event via reflection. As far as I know, its the only way to do it in VB.

    0 讨论(0)
提交回复
热议问题