Validating form close dating and sex for nerds and nice guys

For example a user is filling in data and he inputs something incorrect in a field, but he then quickly wants to close the window by pushing X in the upper right corner.

At the moment validation goes off and show a dialogbox that incorrect data is enterred when I press X.

Note: If the Validation was canceled in the Validating Event, then this event will not be called.

This property indicates whether the control causes validation to be performed on any controls that require validation when it receives focus.

However, I think that a design change would be better: Add an Error Provider "control" to your form and set/clear the Error Provider flag in the Validating and/or Change event.

Also, in that event, check to make sure that there are no controls with Errors, and enable the OK button only when all errors have been cleared. It makes your form look much more professional and auto-magically gives error message.

A good solution is to use the Error Provider control.

It displays an icon next to the control indicating an error as well as displaying an error message when the user hovers the mouse over the icon.

Use this event to handle any needed upkeep after successfully validating the control.I.e., the caret will remain in the textbox until the user enters the correct format.Important: Never attempt to set the Focus of a control in this event because it can cause the script to hang.I have a form with numerous textboxes and I use the validating event to validate these items.If I want to close that form with the X button in the upper right corner of that window validation may not occur.

Leave a Reply