how to disable the GotFocus on textbox?
-
i have textbox that do something on GotFocus. how i can disable the GotFocus on this textbox ? and how to enable it back ? thanks in advance
Presumably you are talking winforms! GotFocus is an event, you can't disable it, you can disable the control or you can handle the problem inside the event.
Never underestimate the power of human stupidity RAH
-
i have textbox that do something on GotFocus. how i can disable the GotFocus on this textbox ? and how to enable it back ? thanks in advance
-
i have textbox that do something on GotFocus. how i can disable the GotFocus on this textbox ? and how to enable it back ? thanks in advance
Gali1978 wrote:
how i can disable the GotFocus on this textbox ?
textBox1.GetFocus -= this.textBox1_GotFocus;
Gali1978 wrote:
and how to enable it back ?
textBox1.GetFocus += this.textBox1_GotFocus;
Alternatively, you could set a flag to indicate your "disabledness" and act on that;
bool isFocusEnabled = false;
void this.textBox1_GotFocus(object sender, EventArgs e)
{
if (!isFocusEnabled) then return; // exit the method if the flag is set
}That'd allow you to disable/enable the execution of the event with a simple boolean.
Bastard Programmer from Hell :suss: