Getting reference to an ErrorProvider

  • Thread starter Thread starter J L
  • Start date Start date
J

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
 
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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top