C windows form validating event Horny free messaging
This will future proof your code as much as possible and prepare you for any breaking changes down the road to the internals of the Framework.
Let’s assume when we click our save button that we wish to validate the controls and display an icon if there is a problem.
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.
In this case, we simply clear any error messages in the error provider.
Each of the controls implements the Validating event.
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 error provider simply takes a control and a message in the Set Error method and does the rest of the work for you!
If the user enters invalid data they’ll see an icon shown in Figure 3.
I am trying to better understand how validation works in a Windows Forms application.