Emptying an eventhandler

Unimatrix_001
Unimatrix_001 used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
To unregister the event handler we can use
buttonInstance.Click -= SomeEventHandler

Thx!
Swaps

Author

Commented:
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...
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Author

Commented:
Nah, afraid not... This is something seperate.
Could you give me a sample?

Author

Commented:
That's the ticket. :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial