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

Posted on 2005-05-03
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?


Question by:brokeMyLegBiking
    LVL 96

    Expert Comment

    by:Bob Learned
    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?  

    LVL 4

    Author Comment

    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
            Return True
        End Function
    LVL 4

    Author Comment

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

    Accepted Solution

    That'll work :)  Sorry, there isn't any easier way, AFAIK.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    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 ( Literal, only instead of starting and ending with w…
    1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now