ErrorProvider is a great way to tell the user that there's something wrong with the data he or she entered. However, if you are developing an application for multiple languages, it becomes very difficult to maintain the messages for the different languages.
You have to set
ErrorText in code, and there is no easy way to maintain these texts, like you do for labels, buttons and the like.
Using the Code
ErrorProvider is a subclassed
ErrorProvider, that allows you to store one piece of text per control. If you want more than one message per control (e.g. "This field must be filled" and "No digits are allowed"), then you would need two
Here's an example for a form that has been marked Localizable
True, with a
After you have entered text in the designer, you get generated code like this:
Private Sub InitializeComponent
Me.Email.Name = "Email"
In the Validating event handler for the control, you put code like this:
Private Sub Email_Validating(ByVal sender As Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles Email.Validating
If (Me.Email.TextLength = 0) _
OrElse (Me.Email.Text.Contains("@") _
AndAlso Me.Email.Text.Contains(".")) Then
- 16 November 2010: Initial version