Prevent the fireing of a textbox leave event

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
 
G

GhostInAK

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
 
W

William E Voorhees

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
 
C

Cor Ligthert [MVP]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top