"warningProvider"

"warningProvider"

Old forum URL: forums.lhotka.net/forums/t/7131.aspx


matt tag posted on Thursday, June 18, 2009

I have always used the (nifty recursive) code below to show all errors on a form bound to CSLA object(s).  As it should, this code skips rules that are set to RuleSeverity.Warning.  Now I would like to show a yellow icon next to the controls that have warnings associated with them.  Has anyone implemented this?


  Public Shared Sub ShowErrors(ByVal oParent As Control, ByVal epErr As ErrorProvider)

        For Each oCtl As Control In oParent.Controls
            For Each oBnd As Binding In oCtl.DataBindings

                Dim o As System.ComponentModel.IDataErrorInfo = _
                    CType(oBnd.DataSource, System.ComponentModel.IDataErrorInfo)

                epErr.SetError(oCtl, o.Item(oBnd.BindingMemberInfo.BindingField))
            Next

            ShowErrors(oCtl, epErr)       'recursion rules!
        Next
    End Sub

matt tag

JonnyBee replied on Friday, June 19, 2009

Hi,

There is an ErrorWarnInfoProvider in the CSLA Contrib project on CodePlex (although in C#) that could be used. Basically what you need is 2 of 3 separate error providers (setup with different icons) and control which one of them shows a message. If you want to display both errors and warnings at the same time it gets a litle more tricky to add offset (right/left) on the icons so that the error providers will not diplay icons on top of each other. This is handled in the ErrorWarnInfoProvider so take a look at that one.

/jonnybee


Copyright (c) Marimer LLC