Home All Groups Group Topic Archive Search About

Getting reference to an ErrorProvider

Author
8 Apr 2005 10:12 PM
J L
I have a from with an ErrorProvider on it. I pass a reference of the
form to a subroutine where I want to reference the ErorrProvider. I
could pass it in the call to the subroutine, but I would like to
dreive it from the reference to the form that I am already passing.

Can this be done?

TIA
John

Author
9 Apr 2005 7:17 AM
Adam Goossens
Hi John,

Sure it can. In your form create a new public property which returns the
instance of your ErrorProvider:

---
Public ReadOnly Property GetErrProvider
    Get
       Return _errorProvider ' or whatever you named the control
    End Get
End Property
---

Regards,
-Adam.

J L wrote:
Show quoteHide quote
> I have a from with an ErrorProvider on it. I pass a reference of the
> form to a subroutine where I want to reference the ErorrProvider. I
> could pass it in the call to the subroutine, but I would like to
> dreive it from the reference to the form that I am already passing.
>
> Can this be done?
>
> TIA
> John
>
Author
9 Apr 2005 2:42 PM
J L
Hi Adam,
Thanks for the tip. Since I have several forms that I need to
"discover" their errorprovider, I was hoping to find a way to do it
like using a For Each loop. But error providers do not show up in the
control collection and I tried components and that did not seem to
work. So if worse comes to worse, I will have to creat a property as
you suggest. Thanks for your input!

John

On Sat, 09 Apr 2005 16:47:46 +0930, Adam Goossens
<adamgooss***@users.sourceforge.net> wrote:

Show quoteHide quote
>Hi John,
>
>Sure it can. In your form create a new public property which returns the
>instance of your ErrorProvider:
>
>---
>Public ReadOnly Property GetErrProvider
>    Get
>       Return _errorProvider ' or whatever you named the control
>    End Get
>End Property
>---
>
>Regards,
>-Adam.
>
>J L wrote:
>> I have a from with an ErrorProvider on it. I pass a reference of the
>> form to a subroutine where I want to reference the ErorrProvider. I
>> could pass it in the call to the subroutine, but I would like to
>> dreive it from the reference to the form that I am already passing.
>>
>> Can this be done?
>>
>> TIA
>> John
>>
Author
10 Apr 2005 8:18 AM
Adam Goossens
John,

Yeah, error providers appear to be strange little things and sit "over"
your form rather than as a part of it (eg, inside the Controls or
Components collections).

I can't think of any other (simple) solution other than implementing a
property. You might consider deriving all of your forms from a common
base class and placing your error provider and accessor property in there.

Good luck,
-Adam.

J L wrote:
Show quoteHide quote
> Hi Adam,
> Thanks for the tip. Since I have several forms that I need to
> "discover" their errorprovider, I was hoping to find a way to do it
> like using a For Each loop. But error providers do not show up in the
> control collection and I tried components and that did not seem to
> work. So if worse comes to worse, I will have to creat a property as
> you suggest. Thanks for your input!
>
> John
>