Prevent the fireing of a textbox leave event

  • Thread starter Thread starter William E Voorhees
  • Start date Start date
W

William E Voorhees

I have code (using the leave event) in a textbox which prevents the user
from leaving the box if it is blank. I would like the user to be able to
click on the [close] button of the form and close that form without firing
the leave event in that text box. An answer would be helpful.

Thanks,

Bill
 
Hello William,

Preventing the user from leaving a text box is really just bad form. Users
don't like it, and it creates headaches for the programmer, as you have experienced.
Typically user input validation is done when the Submit/OK/Apply button
is pressed.. if there is an error you can indicate the error at that time.
It's an extremely rare case where input validation HAS to be done as the
user is typing.

-Boo
 
that's an Answer?

GhostInAK said:
Hello William,

Preventing the user from leaving a text box is really just bad form.
Users don't like it, and it creates headaches for the programmer, as you
have experienced. Typically user input validation is done when the
Submit/OK/Apply button is pressed.. if there is an error you can indicate
the error at that time. It's an extremely rare case where input validation
HAS to be done as the user is typing.

-Boo
I have code (using the leave event) in a textbox which prevents the
user from leaving the box if it is blank. I would like the user to be
able to click on the [close] button of the form and close that form
without firing the leave event in that text box. An answer would be
helpful.

Thanks,

Bill
 
Ghost

In fact did you write in my idea the answer, don't use an own routine, use
the validating events and the errorprovider.

http://msdn2.microsoft.com/en-us/system.windows.forms.errorprovider.aspx

I hope this helps

Cor

GhostInAK said:
Hello William,

Preventing the user from leaving a text box is really just bad form.
Users don't like it, and it creates headaches for the programmer, as you
have experienced. Typically user input validation is done when the
Submit/OK/Apply button is pressed.. if there is an error you can indicate
the error at that time. It's an extremely rare case where input validation
HAS to be done as the user is typing.

-Boo
I have code (using the leave event) in a textbox which prevents the
user from leaving the box if it is blank. I would like the user to be
able to click on the [close] button of the form and close that form
without firing the leave event in that text box. An answer would be
helpful.

Thanks,

Bill
 
Back
Top