djmiller9975
Fri Sep 29 16:18:22 CDT 2006
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,
Herfried K. Wagner [MVP] wrote:
> "Chris Dunaway" <dunawayc@gmail.com> schrieb:
> >> 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?
>
> Note that this will only work if you have not reset/changed the assigned
> text using 'SetError' previously.
>
> --
> M S Herfried K. Wagner
> M V P <URL:
http://dotnet.mvps.org/>
> V B <URL:
http://dotnet.mvps.org/dotnet/faqs/>