VB.NET 2005 Tutorials
Tutorials
VB.NET 2005VB.NET Validation Controls
Table of Contents
VB.NET Validation Controls
VB.NET Validation Controls - Page 2
VB.NET Validation Controls - Page 3VB.NET Validation Controls - Page 2
.
.
.
Error Provider
The Windows Forms ErrorProvider component is used to validate user input on a form or control. It is typically used in conjunction with validating user input on a form, or displaying errors within a dataset. An error provider is a better alternative than displaying an error message in a message box, because once a message box is dismissed, the error message is no longer visible. The System.Windows.Forms.ErrorProvider component displays an error icon ( ) next to the relevant control, such as a text box; when the user positions the mouse pointer over the error icon, a ToolTip appears, showing the error message string.
Let us see an example for CausesValidation and also ErrorProvider in the following illustration:
-
Create a new project in the Visual Studio IDE and
-
Add two text boxes to the Form1.
-
Check to see if the default value of the causes validation is set to true. This means that when the either text box receives the focus, it will cause all the other controls validating events to occur.
-
Add an error provider object from the toolbox. You will see the window like the one in the screenshot below:

-
Now press F5 to execute the application. The following three screenshots will show the output and the error messages.

The following screenshot shows the message box shown by the exception handler in response to the event validating when no data entered in the text box:
The following screenshot shows the message box displayed by the exception handler in response to the EventValidating when text data is entered in the text box.
The following screenshot shows the message box displayed by the exception handler in response to the EventValidating when text data is entered in the text box.
Next Page: VB.NET Validation Controls - Page 3
Comments
jaber_souqi said:

| Can I have more about The validation with ASP.NET 2.0 |
ereemye said:
|
Really good. But i have a problem with creating crystal reports. i used a wizard but it only displays the field titles with out the a vailable information in the database. Now i know am asking the right guy i will be very happy |
kushal kanal; said:
|
well .. i have readed the vb.net validation examples and i was impressed by the article which was putted on it ... now i have learnt how to validated the fields in the project ... well .. now i wanna like 2 know ... the registration form 's fields validation like a password ... etc... if any one knows it ... plz mail me the code of the registeration form validation on the rajahuja18@gmail.com |
Omar said:
| Thanks for the article on validation, the article helped very much. But I want to find out how to do d same procedure with radio buttons and combo box. Where the system forces the user to input correct values. |


