sourcehoh

sourcehoh

  • NA
  • 18
  • 0

Remove Event Handler in C#

Sep 8 2004 4:57 AM
How can I remove event handler for a particular control. I knew that the proper way is like below: button1.Click += new System.EventHandler(button1_Click); // ADD Handler button1.Click -= new System.EventHandler(button1_Click); // Remove Handler But I want some other way which is more flexible, which I don't need to indicate the previous method name in order to remove the event handler( in my example, I need to supply the method name ( button1_click ) to remove. Is that posible to have some other method to remove the handler? As I know in delphi I only need to set the method point to nil ( as below ) button1.onclick := nil; Hope someone can help me in this context , thank you

Answers (1)