You could keep an ArrayList of all the delegates you've added to the event
and then remove them one by one using the -= operator.

Signature
Regards,
Nish [VC++ MVP]
> In general, some controls can have events handlers attached to them,
> typically via the += operator. How does one remove an event handler added
> this way? Or, just as good for my purposes, how can one remove all event
> handlers attached?
Peter Oliphant - 06 Oct 2005 21:51 GMT
So, if i understand, I'd should do something like this (code inside a class,
hence the 'this' reference):
EventHandler* handler = new EventHandler( this, m_Handler ) ; //
this->m_Handler is of proper form
timer->Tick += handler ;
and then remove it via:
timer->Tick -= handler ; // this 'handler' is the same variable as above
Is this correct?
> You could keep an ArrayList of all the delegates you've added to the event
> and then remove them one by one using the -= operator.
[quoted text clipped - 3 lines]
>> this way? Or, just as good for my purposes, how can one remove all event
>> handlers attached?
Marcus Heege - 06 Oct 2005 21:55 GMT
I guess there is no need to keep an ArrayList of all the delegates you've
added. You can use MulticastDelegate::GetInvocationList to get an array of
all single cast delegates.
Marcus
> You could keep an ArrayList of all the delegates you've added to the event
> and then remove them one by one using the -= operator.
[quoted text clipped - 3 lines]
>> this way? Or, just as good for my purposes, how can one remove all event
>> handlers attached?