C windows form validating event

20 Apr

You do not have to disable the Form’s Auto Validate property.However, I prefer to call it explicitly and handle all validation at once since you most likely will take action only if the entire control’s children pass validation. The most important thing to recognize here is how precise you can be with the validation error message in the error provider.

4) Depending on the valid state, let the form close (Dialog Result = OK) or keep the form open (Dialog Result = None).

I default everything to not Cause Validation, enables them all before I use the event for validating the whole form, and disables them all after again. 2) Write a validation routine, maybe directly under the button click, that loops through the control collection, checking the value/validity of the control's content.

Maybe defer to a private method per control if the validation is complex.

in case extra validation like restricting validation to some of the controls only, that would be decided at the function calling level.

In my windows form projects , i have validated the fields using Boolean method.