How to get the set events of a control?

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2012-06-07T22:36:38Z Indexed on 2012/06/07 22:40 UTC
Read the original article Hit count: 107

Filed under:
|
|

It's possible via C# code get an list of methods/delegates that was set to Control? let me explain better.. For example.

Assuming some definitions like this:

foo.Click += (a, b) => { ... }
//..
foo.Click += (A,B) => { ... }

And a megic method:

var baa = foo.GetEvents("Click");

Returns

baa[0] points to (a, b) => { ... }

baa[1] points to (A,B) => { ... }

My scenery: I make and add dynamically event to some controls inside a loop. I want depending to a boolean value a event of control of index one,will removed by using control.Click -= baa[1] or something like this. I hope this is clear for your. Thanks in advance.

© Stack Overflow or respective owner

Related posts about c#

Related posts about events