Home > DeveloperSection > Articles > ErrorProvider Control in VB.Net

ErrorProvider Control in VB.Net

VB.Net VB.Net 
0 Comment(s)
 13368  View(s)
Rate this:

ErrorProvider Control in VB.Net

ErrorProvider allows us to set an error message for any control on the form when the input is not valid. When an error message is set, an icon indicating the error will appear next to the control and the error message is displayed as Tool Tip when the mouse is over the control.

Drag and drop ErrorProvider and TextBox  control from toolbox on the window Form.

ErrorProvider Control in VB.Net

ErrorProvider Control in VB.Net

Drag and drop a Button.

ErrorProvider Control in VB.Net



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        If TextBox1.Text = "" Then ' condition is given so that empty textbox could not save

ErrorProvider1.SetError(TextBox1, "Cannot leave textbox blank")'error text will show as tooltip



            ErrorProvider1.SetError(TextBox1, "")

        End If


    End Sub

End Class

Run the project

ErrorProvider Control in VB.Net

If textbox is empty and Submit button is clicked then error icon will display.

ErrorProvider Control in VB.Net

When any value (text or number) is entered in textbox and Submit button clicked then form will execute.

ErrorProvider Property:

Icon property:   which allows us to set an icon that will be display when error occurred?

 BlinkRate property:   which allows setting the rate in milliseconds at which the icon blinks.

Icon:    Gets or sets the Icon that is displayed next to a control when an error occurred. 

BlinkStyle:   Gets or sets a value indicating when the error icon flashes. 

Don't want to miss updates? Please click the below button!

Follow MindStick