I'm using a custom icon in my ErrorProvider with
ErrorProvider.BlinkStyle = ErrorBlinkStyle.NeverBlink
I've got a problem with overlapping icons using code that is similar to this one:
public partial class TestForm : Form
{
private ErrorProvider _errorProvider1;
private ErrorProvider _errorProvider2;
private CheckBox _control1;
private CheckBox _control2;
//...
private void ValidateAll()
{
_errorProvider1.Clear();
_errorProvider2.Clear();
_errorProvider1.SetError(_control1, string.Empty);
_errorProvider2.SetError(_control2, string.Empty);
if(Validate(_control1.Checked))
{
_errorProvider1.SetError(_control1, "Error1");
}
if(Validate(_control2.Checked))
{
_errorProvider2.SetError(_control2, "Error2");
}
}
//...
}
I'm interacting with _control1 while _control2 has some error (is Checked), thus _errorProvider2 has some error set. Everytime method ValidateAll is called it will correctly set _errorProvider1 for _control1 but _control2 _errorProvider2 will keep drawing extra icons without erasing old ones.
After 'clicking' _control1 multiple times
When interacting with _control2, _errorProvider2 will go back to normal, but _control1's _errorProvider1 will do the same until it is 'clicked'.
Please note that underlying Control doesn't affect it; it doesn't have to be CheckBox.
What I tried:
- Using only one ErrorProvider per Form/Control,
- Focusing each Control before setting ErrorProvider,
- Not clearing ErrorProviders
Any help is much appreciated, thanks!