Required Fields


Author
Message
Paul Chase
Paul Chase
Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)Advanced StrataFrame User (806 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
I am working on an app where the users would like to easily identify the required fields before getting the required fields error upon save. I was thinking about a different back color or something along those lines.

I haven't really started to poke around on how to accomplish this but am thinking I will need to create a subclass of MicroFour.StrataFrame.Business.BusinessLayer add a property to store the back color.

Then in some Form method\event? add the code to loop through the required fileds collection and the forms controls and set the approriate back colors on the controls that are bound to required fields. So I guess my question is what would be the appropriate event to add the code to do this. Or is there a better way to accompish this?

Any pushes/shoves in the right direction would be welcome.

Thanks

Paul

Reply
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
It would look something like this...this is not tested, I just typed it in here.  This code would go in your business object...so you would more than likely want to create a subclass of BusinessLayer so you only have to write this code once:

Private _RequiredProvider As ErrorProvider

    Public Sub ShowRequiredFields()
        '-- Establish Locals
        Dim loItem As MicroFour.StrataFrame.Business.IRequiredField
        Dim loControl As Control

        _RequiredProvider = New ErrorProvider(CType(Me.ParentContainer, ContainerControl))
        _RequiredProvider.Icon = YourIconFile
        ' Place any addition provider settings

        '-- Cycle through the required fields
        For Each loItem In Me.RequiredFields
            '-- Get the control
            loControl = GetBoundControl(loItem.FieldName)

            If loControl IsNot Nothing Then
                _RequiredProvider.SetError(GetBoundControl(loItem.FieldName), "Required Field")
            End If
        Next
    End Sub

    Private Function GetBoundControl(ByVal FieldName As String) As Control
        '-- Establish Locals
        Dim loControl As Control = Nothing
        Dim loItem As MicroFour.StrataFrame.UI.Windows.Forms.IBusinessBindable

        '-- Cycle through the bound controls
        For Each loItem In Me.BoundControls
            If loItem.BindingField.Equals(FieldName) Then
                loControl = CType(loItem, Control)
                Exit For
            End If
        Next

        '-- Return Results
        Return loControl
    End Function

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Paul Chase - 19 Years Ago
StrataFrame Team - 19 Years Ago
Paul Chase - 19 Years Ago
StrataFrame Team - 19 Years Ago
Paul Chase - 19 Years Ago
                         Would you care to share this code with this "Newbie"? That is actually...
Ben Kim - 19 Years Ago
                             It would look something like this...this is not tested, I just typed...
Trent L. Taylor - 19 Years Ago
                             [quote][b]Ben Kim (11/08/2006)[/b][hr]That is actually a requirement...
Greg McGuffey - 19 Years Ago
                             I second this too!

:P
Chan - 18 Years Ago
Larry Caylor - 18 Years Ago
             Excellent idea! :D
Greg McGuffey - 18 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search