Link to home
Start Free TrialLog in
Avatar of Unimatrix_001
Unimatrix_001Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Emptying an eventhandler

Hi,

I know I can bind an event to a handler as follows:

buttonInstance.Click+=SomeEventHandler

But is there a way to empty the event of all handlers?

Thanks,
Uni
Avatar of k_swapnil
k_swapnil
Flag of India image

To unregister the event handler we can use
buttonInstance.Click -= SomeEventHandler

Thx!
Swaps
Avatar of Unimatrix_001

ASKER

I'm away of being able to do that, but I'm ideally wanting a way to clear it without having to refer to individual event handlers otherwise it means I need to keep track of which ones have been added...
Is it something to do with the multiple buttons you created?
If yes then do the following
foreach(Button button in panel1.Controls)
{
button.Click -= SomeEventHandler;
}

Thx!
Swaps...
Nah, afraid not... This is something seperate.
Could you give me a sample?
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's the ticket. :)