Dom,
You can remove all the event handlers with the following code:
public EventHandler MyEvent;
foreach (EventHandler eventHandler in
MyEvent.GetInvo cationList())
{
MyEvent -= eventHandler;
}
In this snippet, you can use the -= operator as you get a reference to
each handler suscribed to the event. In the other hand, operator --
cannot be used with events.
I hope it helps,
Seba
On Mar 20, 11:41 am, "Marc Gravell" <marc.grav...@g mail.comwrote:
You can only remove event-handlers that you know about. For example, if you
have:
void SomeHandler(obj ect sender, KeyPressEventAr gs e) {...}
then you can use:
t.KeyPress -= SomeHandler;
or (identical)
t.KeyPress -= new KeyPressEventHa ndler(SomeHandl er);
if you have used an anomymous function/lambda, then you'll need to cache the
delegate instance prior to subscribing, and unsubscribe with the same:
KeyPressEventHa ndler handler = (sender, e) ={}
t.KeyPress += handler;
//...
t.KeyPress -= handler;
Marc