I want to use a single ErrorProvider for my entire form by adding
control/error combinations using:

myErrorProvider.SetError(textBox1, errorMessage1);
myErrorProvider.SetError(textBox2, errorMessage2);

This works with no problems. However, I want to be able to easily
clear *all* errors that the provider is bound to. I realize that I
can set do this via the following:

myErrorProvider.SetError(textBox1, "");
myErrorProvider.SetError(textBox2, "");

...but since there will be a lot of controls on the page I'm hoping
there's some way to simply clear all.

myErrorProvider.Clear(); //alas, i know this doesn't exist...

anyone have any suggestions?
TIA

Re: clear all errors with ErrorProvider by Gerben

Gerben
Sat Aug 02 05:46:01 CDT 2003

Hi Tim,

A while ago I was aslo searching for it but couldn't find anything. I just
mode a simple loop to reset all errors, something like this:

foreach(Control cr in this.Controls)
{
errorProvider1.SetError(cr,"");
}

Hope it helps,

greets Gerben

"Tim Chantome" <chantomet@cintas.com> wrote in message
news:fb96c8e2.0308010910.4bf918b3@posting.google.com...
> I want to use a single ErrorProvider for my entire form by adding
> control/error combinations using:
>
> myErrorProvider.SetError(textBox1, errorMessage1);
> myErrorProvider.SetError(textBox2, errorMessage2);
>
> This works with no problems. However, I want to be able to easily
> clear *all* errors that the provider is bound to. I realize that I
> can set do this via the following:
>
> myErrorProvider.SetError(textBox1, "");
> myErrorProvider.SetError(textBox2, "");
>
> ...but since there will be a lot of controls on the page I'm hoping
> there's some way to simply clear all.
>
> myErrorProvider.Clear(); //alas, i know this doesn't exist...
>
> anyone have any suggestions?
> TIA



Re: clear all errors with ErrorProvider by chantomet

chantomet
Mon Aug 04 08:47:20 CDT 2003

thanks for the replies. I hacked up a decent solution by writing a
AddError method that simply adds the control to an ArrayList and then
a ClearErrors method that rips thru each item in the collection and
re-initializes each control's respective error.

This prevents looping thru the entire form's controls collection, and
provides a way to reach nested controls (panels, UCs, tabs, etc).

happy coding...

Re: clear all errors with ErrorProvider by JerryK

JerryK
Thu Aug 14 00:24:49 CDT 2003

Would would this not work with nested controls? If you put in a routine and
called is recursively passing the parent control would that not work?

"Herfried K. Wagner" <hirf.nosp@m.activevb.de> wrote in message
news:u6e4KuOWDHA.1480@tk2msftngp13.phx.gbl...
> Hello,
>
> "Gerben van Loon" <nospamplz_gerbenvl@home.nl> schrieb:
> > A while ago I was aslo searching for it but couldn't find
> > anything. I just mode a simple loop to reset all errors,
> > something like this:
> >
> > foreach(Control cr in this.Controls)
> > {
> > errorProvider1.SetError(cr,"");
> > }
>
> Notice that this will not work with nested controls.
>
> HTH,
> Herfried K. Wagner
> --
> MVP · VB Classic, VB .NET
> http://www.mvps.org/dotnet
>
>