ErrorProvider Property

D

Dwight

Hi,
I know how to set the message for an ErrorProvider through code when
handling a validating event, however, I would like to use the message
that is entered at design time in the properties window for a given
control. ie. Error or ErrorProvider1. How can I use this message with
the seterror method?
 
C

Chris Dunaway

Dwight said:
Hi,
I know how to set the message for an ErrorProvider through code when
handling a validating event, however, I would like to use the message
that is entered at design time in the properties window for a given
control. ie. Error or ErrorProvider1. How can I use this message with
the seterror method?

Looking at the properties and methods of the ErrorProvider class in the
docs, I found the GetError method.

Perhaps that is what you need?
 
H

Herfried K. Wagner [MVP]

Chris Dunaway said:
Looking at the properties and methods of the ErrorProvider class in the
docs, I found the GetError method.

Perhaps that is what you need?

Note that this will only work if you have not reset/changed the assigned
text using 'SetError' previously.
 
D

djmiller9975

Do you have any suggestions on how to use this? What is the purpose of
provding the property as design time? In order to clear an error when
it happens, you have to set the error message for the control to ""
esentially changing the property.

Also, using the geterror method of the error provider doesn't return
anything until after you set the error. Here's what I was hoping to
do;

Set one event handler for several textbox controls that cannot be left
blank and use the following code as part of the validating event:

Dim ctrl As Control = DirectCast(sender, Control)
If Len(ctrl.Text) = 0 Then
ErrorProvider1.SetError(ctrl, ErrorProvider1.GetError(ctrl))
Else
ErrorProvider1.SetError(ctrl, "")
End If

I was hoping this would use the Error on ErrorProvider1 property of the
corresponding control.

Any suggestions?

Thanks,
 

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

Top