Windows form control validating validated

6854933580_2c8b688306_z

The easiest way to find out how to do something from code is to setup the control the way you want it using designer and then explore Initialize Component() method. Error Provider = my Error Provider1 super Validator1. You assign your custom error provider to Custom Error Provider property.Here is simple setup for Super Validator control: C# Dev Components. 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.As you can see in the example, Validate Children is called as a result of the Click event causing the Validating event to be sent to each of the controls.The app also uses an Error Provider control to give the user feedback.You can use this for example to ensure that password entered matches the confirmation password on input form or to ensure that numeric input value is greater than number you specify.

windows form control validating validated-9windows form control validating validated-88windows form control validating validated-29windows form control validating validated-89

For example you can require the input for text-box and enforce the format to be an email by assigning Validation1 and Validation2 properties.Super Validator can work with any of these components set or without any of them at all if you are planning to report validation results some other way.Next step is to choose the way Super Validator performs validation.In this case, we simply clear any error messages in the error provider.The Name textbox works very similarly but we don’t have quite as elaborate validation logic.The "real application" has a dialog with many Text Box controls.

You must have an account to comment. Please register or login here!