Home All Groups Group Topic Archive Search About

Prevent the fireing of a textbox leave event

Author
17 Jun 2006 3:32 AM
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

Author
18 Jun 2006 12:43 AM
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

Show quoteHide quote
> 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
>
Author
18 Jun 2006 4:15 AM
William E Voorhees
that's an Answer?

Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> wrote in message
news:c71747b417e408c860444181167a@news.microsoft.com...
> 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
>>
>
>
Author
18 Jun 2006 6:43 AM
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

Show quoteHide quote
"GhostInAK" <ghosti***@gmail.com> schreef in bericht
news:c71747b417e408c860444181167a@news.microsoft.com...
> 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
>>
>
>