There are 2 code paths for validation failure, and in each case we provide the user with an appropriate error message.
The error provider simply takes a control and a message in the Set Error method and does the rest of the work for you!
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.
If the user enters invalid data they’ll see an icon shown in Figure 3.
After the validating event returns without being cancelled, meaning we have valid user input, then the validated event will be raised.
This is fine if your only concerned about the data that is entered being correct.
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.
And, what should be Datasource Update Mode- On Property Changed or On Validation?
I want to check what the user is writing in a textbox before I save it in a database. I guess I can always write some ifs or some try-catch blocks, but I was wondering if there's a better method.