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

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You could either change the back color or use your own ErrorProvider with the icon set to a little green dot or yellow arrow.  Your best bet would probably be to add this functionality to the business object in the inherited class you were talking about.  In the EditingStateChanged event of the business object, you could cycle through the BoundControls collection of the business object and compare the bound field to the required fields collection and if it's required, then add your adornment.
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
Ben,

I was thinking about this a bit more. I think I only need to show that the controls are required feilds when a user adds a new record. Thanks for suggesting the error provider I think it will look a bit nicer. 

Thanks

Paul

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
No problem.  The error provider is just a basic .NET control, in case you didn't already know that Smile
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
Thanks again Ben I implemented it this morning and it works like a champ.
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Would you care to share this code with this "Newbie"?  That is actually a requirement we have for our applications also.  Perhaps this should be an option in StrataFrame? ;-)

Ben

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

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Ben Kim (11/08/2006)
That is actually a requirement we have for our applications also. Perhaps this should be an option in StrataFrame? ;-)




I'll second this! BigGrin
Chan
Chan
Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)Advanced StrataFrame User (965 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
I second this too!



Tongue
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

I’d also like to see this as part of the standard framework. And while we’re talking enhancements, I’d still like to see support for warning messages. I’d like to be able to strongly suggest to the user that a field should be entered using a business rule, but not prevent them from saving the object if the field is left blank.

-Larry

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search