how to do this? I only know how to set the error

errorprovider.seterror(textbox, "message);

remove the error

error.provider.seterror(textbox, "");

But instead of just removing the error, I want to display something like a check mark.

Recommended Answers

All 4 Replies

The errorProvider only has one icon which is displayed against all controls which have an error text set so you couldnt show a tick for some controls and a cross for others withthe same errorProvider. One option would be to have two errorProviders. Use one to show errors and the other to show correct values. Something like:

if(textBox.Text != "") //if data valid
{
    errorProviderValid.SetError(textBox, "Input Valid");
    errorProviderInValid.SetError(textBox, "");
}
else
{
    errorProviderValid.SetError(textBox, "");
    errorProviderInValid.SetError(textBox, "Cannot be blank");
}

Then set the icon of errorProviderValid to a tick icon and leave errorProviderInvalid with the default cross icon.

how to set the icon of errorprovider to a tick icon?

In the designer you can change the Icon property. Create/download a suitable tick icon and set assign it to your Valid error provider. I'd also recommend setting the BlinkStyle property to NeverBlink since it will look unsightly and possibly confusing if all your ticks are flashing when input is valid.

How to show success icon?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.