I want to be able to disable or enable textchanged event when I need to. I have made my function, but I need to dismiss event handler, how can I do that?
Here is my code:
private void textBox1_TextChanged(object sender, EventArgs e)
{
//something
}
This to add the event
textBox1.TextChanged += new TextChangedEventHandler(textBox1_TextChanged);
this to remove the event
textBox1.TextChanged -= new TextChangedEventHandler(textBox1_TextChanged);
Or just the method name
This to add the event
textBox1.TextChanged += textBox1_TextChanged;
this to remove the event
textBox1.TextChanged -= textBox1_TextChanged;
Hope it helps.
simply un-register the event
yourEvent-= YourFunction
and if you want to register again
yourEvent+= YourFunction
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With