Retrieve all delegates registered for one event

  • Thread starter Thread starter Lore Leuneog
  • Start date Start date
L

Lore Leuneog

Hi.

You can add new delegates for an event with += and you can remove delegates
from an event by using: -= but is there a way (method) to list all delegates
added to one event???

Sincerely
Greetings
Lore
 
Hi Lore,

Yes, this is possible.
You can use the GetInvocationList() method in your event,
which returns the list of delegates that have been associated with
the event.

MyDelegate[] delegates = (MyDelegate[])MyEvent.GetInvocationList();

Regards,
Aravind C
 
Hi, Aravind

Thank you very much.
But it seems this doesn't work with build-in Form-Control-Events for example
this.Button.Click-event?
(EventHandler[])this.button.Click.GetInvocationList();
Doesn't work?!

Or did I do it wrong?
Sincerely
Marane



Aravind C said:
Hi Lore,

Yes, this is possible.
You can use the GetInvocationList() method in your event,
which returns the list of delegates that have been associated with
the event.

MyDelegate[] delegates = (MyDelegate[])MyEvent.GetInvocationList();

Regards,
Aravind C


Lore Leuneog said:
Hi.

You can add new delegates for an event with += and you can remove delegates
from an event by using: -= but is there a way (method) to list all delegates
added to one event???

Sincerely
Greetings
Lore
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top