CheckRulesOnRow on TextChanged


Author
Message
Marcel Heitlager
Marcel Heitlager
StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)
Group: StrataFrame Users
Posts: 84, Visits: 835
BindingUpdateMode is set to OnPropertyChanged.  I'm trying to activate/deactivate a button depending on whether all required fields are filled in. 

I figured I could do a CheckRulesOnRow when the textbox_TextChanged event occurs.  But it seems that the business object hasn't been updated yet at this point.  Is there a way to do this after the bo has been updated with the new value?

Thanks,

Marcel

Marcel Heitlager
Marcel Heitlager
StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)StrataFrame User (202 reputation)
Group: StrataFrame Users
Posts: 84, Visits: 835
OK, after some further thought this is what I came up with.  Am I killing a mosquito with an ICBM?

I added a custom field property to my business object (lValidated), added a propertychanged sub for each required field, which call me.CheckRequiredFieldRules function.  Then on the form, the button's, enabled property is bound to the business object.

In business object:

Private _lValidated As Boolean = False

<Browsable(False),
BusinessFieldDisplayInEditor(), _
Description(
"Boolean, Are All Required Fields Validated?"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public ReadOnly Property [lValidated]() As Boolean

  Get

      Return _lValidated

  End Get

End Property

Protected Overrides Function GetCustomBindablePropertyDescriptors() _ As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

    Return New FieldPropertyDescriptor() {New ReflectionPropertyDescriptor("lValidated", Me.GetType())}

End Function

Private Sub CheckRequiredFieldRules()

   Dim llValidated As Boolean

   llValidated = Me.CheckRulesOnRow()

   If llValidated Then

      Me._lValidated = True

   Else

       Me._lValidated = False

   End If

End Sub

Private Sub boParticipants_address1Changed(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.address1Changed

   Me.CheckRequiredFieldRules()

End Sub

Then on the button I set:
BindingField = lValidated
BindingProperty = Enabled
BindingUpdateMode = Never
BusinessObject = boParticipants
ControlSourceUpdate = OnPropertyChanged

And I turned then little error arrows off

I took some of it from other posts.  Oh, and I know I could use an IIF() instead of If..then. One thing I like is that all the logic is in the Business Object. 

Thanks

Marcel

 


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
OK...what you did will work, but it may be more energy than you really need to implement...especially to reproduce over and over again.

First, if the update mode is set to OnPropertyChanged, and the BO does not show the changes in the OnTextChanged event, then it is a matter of handler order.  In other words, the TextChanged event that you are handling is being fired BEFORE the base.  If you want to prove this, create a MyTextBox class, inherit the SF TextBox, then override the OnTextChanged event and place your code AFTER the MyBase.OnTextChanged call.  This should then prove where the issue was and then you can start to work the problem so that it may be easier to implement this same logic in the future.

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