C windows form validating event

This might be a common scenario in data entry forms where you might create a new record and the user might not touch all the fields on your form (and thus never trigger the “Validating” event of your controls). One, pointed out by Chris Sells (read more), invokes the Control's “Notify Validating” event through Reflection.Here is an example: You can also trigger the Validation event by giving focus to a control and taking the focus away.You might even loop through all the controls on your form and focus each of them individually (or an individual control by giving it focus then changing the focus to another control), achieving the same effect: Which solution is better?I'd recommend staying away from reflecting on the internal methods and properties of Framework classes.As a follow up to my previous post about enhancing the validation controls within Windows Forms, there might be times when you would like to manually invoke the “Validating” event of a control.For example, you might want to have a routine that fires on the form's “Closing” event or a data save method to loop through all the controls on your form and validate them independently to ensure that all controls are valid.

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.

So while this seems to work, I am left feeling that that I "colored outside of the lines".

Is there a "best practice" document/site for control validation in a Windows Forms application?

The app also uses an Error Provider control to give the user feedback.

Yesterday, I did not understand how to use the Ok button Click event to perform this validation. Clicking the Ok button causes the Error Provider to do it's thing where a control is not valid and the dialog is not closing unexpectedly.

Search for c windows form validating event:

c windows form validating event-65

I am trying to better understand how validation works in a Windows Forms application.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “c windows form validating event”