When user clicks Calculate, you can check whether the required fields contain required values in expected ranges.If not you can "Show" message accordingly, instructing the user to enter correct values.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.Way back when I designed the software I decided how the UI going to work for textboxes, listboxes, combo boxes, etc.Also different levels of severity is handled differently.I'll add a code sample in a [email protected] LG that is what i am doing right now! For instance, take the validation controls we have in ASP. I feel the validation controls, since they are positioned right next to the input controls help the user immediately understand what he's doing wrong and thereby give him a better experience.
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.
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.
Is there a "best practice" document/site for control validation in a Windows Forms application?
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.