articles

Home / DeveloperSection / Articles / ErrorProvider Control in C#.Net

ErrorProvider Control in C#.Net

Anonymous User17153 24-Jan-2011

ErrorProvider simplifies and streamlines error presentation. It is an abstraction that shows errors on your form. It does not require a lot of work on your part. This is its key feature.

How to use ErrorProvider Control

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


ErrorProvider Control in C#.Net

ErrorProvider Control in C#.Net

Code:

Write code on Button click event.

ErrorProvider Control in C#.Net

Double click on Click event.

private void btnSubmit_Click(object sender, EventArgs e)
{
          if (textBox1.Text == "")//condition is given so that empty textbox could not save
            {
            errorProvider1.SetError(textBox1, "Cannot leave textbox blank");
                //error text will show as tooltip
            }
           else
            errorProvider1.SetError(textBox1, "");
         label3.Text = "Entered name is " + textBox1.Text;
}

Run The Project

ErrorProvider Control  in C#.Net

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

ErrorProvider Control  in C#.Net

When name is entered in textbox and Submit button clicked then entered name will show in Label.

ErrorProvider Control  in C#.Net

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:    Set 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



c# c# 
Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By