?
Solved

errorProvider, is there an easy way to tell if all controls are valid?

Posted on 2005-05-03
4
Medium Priority
?
221 Views
Last Modified: 2010-04-23

I am using an errorProvider control on my form. Is there an easy way to tell if all controls are valid without having to loop through all the controls on my form?

does the errorProvider keep track of which controls on the form have been set with the error message? Or at least a count of how many have been placed in error status?


thx,

Joseph
0
Comment
Question by:brokeMyLegBiking
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13925929
The ErrorProvider control is has a Property Extender to add the Error property for each control.  It is not a validator, so it is up to you to control how it functions to display errors.

The equivalent for the design-time property, during run-time, is the ErrorProvider.SetError method.  It basically sets the Error message property for each control specified.

How are you using it now?  

Bob
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 13926069
I figured out a way to do it. I created a function which loops through each control on the form, and checks if it's error value is "", if any of the error values are not blank it returns false.



    Public Shared Function all_controls_are_valid(ByVal frm As Form, ByVal errProvider As ErrorProvider) As Boolean
        For Each con As Control In utilities.get_controlTagCol(frm)
            If errProvider.GetError(con) <> "" Then Return False
        Next
        Return True
    End Function
0
 
LVL 4

Author Comment

by:brokeMyLegBiking
ID: 13926077
I was just hoping that there was a built in function in the errorProvider that did this for me. Perhaps in Visual Studio 2005 if I'm lucky.
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 13926096
That'll work :)  Sorry, there isn't any easier way, AFAIK.

Bob
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question