Windows form control validating validated

Posted by / 13-Mar-2019 14:54

You are already halfway there if you are considering making a class to hold your validation logic this will get you the rest of the way in your new design. When this is set to true (it is true by default) then the control participates in validation. In fact the focus events are fired in a specific order.

From MSDN: When you change the focus by using the keyboard (TAB, SHIFT TAB, and so on), by calling the Select or Select Next Control methods, or by setting the Container Control..::.

Depending on the state of your form that may be more work than your willing to invest. You can have a single validating event and validate the controls there.

There will be no need of using loops and each control will be validated as the data is entered.

Also different levels of severity is handled differently.

The View takes care of that instructing the Form what to do through the Interface.

But this doesn't work well if you're trying to make sure a user didn't leave a textbox empty by skipping over it.

In my solution, when the user clicks the submit button for a form, I check each control on the form (or whatever container is specified) and use reflection to determine if a validating method is defined for the control. If any of the validations fail, the routine returns a failure and allows the process to stop.

It can be the whole form, or just a container on the form like a Panel or a Group.

Now I admit I haven't thoroughly researched ELVAB but it like overkill for what I need.

My current thought is to write a class library with the various requirements and pass it a control as a parameter.

This solution works well especially if you have several forms to validate.

1) Just copy and paste this section of code to your project. Reflection to your using statements 3) Don't skip this step!

windows form control validating validated-70windows form control validating validated-41windows form control validating validated-53

I already have a Library of Reg Ex functions for things like and such so that may be a place for me to start.

One thought on “windows form control validating validated”