Validating windows forms dating encounters
Thankfully Win Forms has built in mechanisms to help facilitate data validation.
Each control has the following events and properties that are used to validate a form. Validation on a control is triggered when the control loses focus. Cancel Event Args] object as a parameter to the event block, which you can access this by using the in the Validating event, all events that would usually occur after the Validating event are suppressed.
In a Win Form I'm doing initial validation in the Form. To make the code short only three fields are shown in the code.
Furthermore, it's unnatural to conceptualize the steps of validation as of the data to be validated.
Code Snippet: Validate the Date Selection Invoking the Set Error method of the Error Provider control displays an error indicator image next to the control specified as the first argument to the the Set Error method.
The string specified in the second argument in the function invocation is displayed as the tooltip when the mouse is moved over the Error indicator.
The control is added to the form and displayed in the control tray in the Windows form in Design view. Now create an event handler for the “Validating” event of the text Box1 control.
We will validate the Text Box to ensure that the user has entered a value.