Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I unregister all handlers for a form event?

Tags:

c#

handler

I have 2 handlers using the same form. How do I remove the handlers before adding the new one (C#)?

like image 332
Joshua Avatar asked Dec 05 '25 06:12

Joshua


1 Answers

If you are working in the form itself, you should be able to do something like:

PseudoCode:

Delegate[] events = Form1.SomeEvent.GetInvokationList();

foreach (Delegate d in events)
{
     Form1.SomeEvent -= d;
}

From outside of the form, your SOL.

like image 51
FlySwat Avatar answered Dec 07 '25 19:12

FlySwat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!