Can't get Invocationist of a butons Click Event

  • Thread starter Thread starter Boaz Ben-Porat
  • Start date Start date
B

Boaz Ben-Porat

I am trying to retrieve the invikation list for aClick event of a button,
and it seems impossible.

The code:

Delegate[] dels = _testButton.Click.GetInvocationList();

I get compiler error:

The event 'System.Windows.Forms.Control.Click' can only appear on the left
hand side of += or -=

Is there a solution?

TIA

Boaz Ben-Porat

Milestone Systems
Danmark
 
Events are deliberately only intended to be accessed internally to the
owning class. If you need to fire the event, then look for an
On{EventName} method, such as OnClick();

You could probably hack something using reflection, but it would be
very, very messy.

Let me turn this question around a bit:

*why* do you need to do this?

Marc
 
Additional; Button.OnClick() is protected, but there is a public
Button.PerformClick() that may be of use.

Marc
 
Thank you Marc.

I can atually achive my goal without doing this, so I don't *need* it.
It could be usefull sometimes to know who is subscribed to a given event.

Boaz
 
Back
Top