When using a Delegate, I can use Delegate.GetInvocationList() Method to retrieve the invocation list of the delegate at runtime.
Is there a way to access the subscriber list that has been associated with an event? I ran the code from this example (SO#1237001) and the immediate window allowed me to cast the SecondChange event to a System.MultiCastDelegate and then invoke the GetInvocationList method.
However, in my scenario I am working with a System.Windows.Forms.DataGridView and I would like to inspect the invocation list of the CellClick event at runtime. However, when I try any kind of cast on CellClick, I recieve the following error:
The event 'System.Windows.Forms.DataGridView.CellClick' can only appear on the left hand side of += or -=
I can see there are clearly differences in the declarations of these events. In the Clock example the event is declared like this:
public event Func<DateTime, bool> SecondChange;
And in the DataGridView the event is declared like this:
[SRDescription("DataGridView_CellClickDescr"), SRCategory("CatMouse")]
public event DataGridViewCellEventHandler CellClick
{
add
{
base.Events.AddHandler(EVENT_DATAGRIDVIEWCELLCLICK, value);
}
remove
{
base.Events.RemoveHandler(EVENT_DATAGRIDVIEWCELLCLICK, value);
}
}
Why can one call GetInvocationList on the Clock example, but not on the DataGridView event? Is there any way for me to get the same type of information from the DataGridView event that GetInvocationList returns?