471,326 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,326 software developers and data experts.

Simple ErrorProvider question

I've never used this little control, but found a reason too. So, I want to
prevent the user from moving on, until the error condition has been
satisified. I have a textbox and raise the Validated event that does the
errorchecking. If an error exists, i don't want the user to move on, what's
the best way to handle this?

Doug
Jan 24 '06 #1
2 1039
Doug,

If there is an error, then you should set the Cancel property on the
CancelEventArgs instance passed to your Validating event handler to true.
This will cause the focus NOT to shift.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
I've never used this little control, but found a reason too. So, I want
to prevent the user from moving on, until the error condition has been
satisified. I have a textbox and raise the Validated event that does the
errorchecking. If an error exists, i don't want the user to move on,
what's the best way to handle this?

Doug

Jan 24 '06 #2
You want to check for errors in the Validating event, not the Validated
event, and then, as Nicholas pointed out, set the Cancel property of
the ValidatingEventArgs to false in order to stop the focus change.

The Validated event is useful if you need code to take action _only if_
the validation succeeded and the user is about to leave the field as a
result.

Jan 24 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Martijn Leine | last post: by
6 posts views Thread by M O J O | last post: by
reply views Thread by Issac | last post: by
8 posts views Thread by Abul Hasan | last post: by
3 posts views Thread by Jeppe Jespersen | last post: by
4 posts views Thread by ljlevend | last post: by
5 posts views Thread by Alvaro Lamas | last post: by
4 posts views Thread by Freeon | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.