Best practice for changing form values


Author
Message
Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
Great thanks, that's just what I was looking for.  BigGrin
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
Andria,

Pauls example is very good and it will keep the logic within the BO using this approach and it is probably the cleanest solution.  There are also times that this may be more of a "one-time-thing" and I might handle a SelectedIndexChanged event or a TextChanged event, something of that nature, to add the logic.  However, this does break encapsulation and if the same logic is required in another location then you are asking for a bug.  The best and safest approach is Pauls example.

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
Andria,

I am doing this type of thing by having the BO raise a field changed or changing event and then handling that event and setting the values. It works out great except if with a business binding source, then you will run into some issues with this appoach.

You can also just add the code to the set method of the field to change the values of the other fields as well.

''' <summary>

''' cki_Amount

''' </summary>

''' <remarks></remarks>

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("cki_Amount"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [cki_Amount]() As System.Decimal

Get

Return CType(Me.CurrentRow.Item("cki_Amount"), System.Decimal)

End Get

Set(ByVal value As System.Decimal)

'Set the Value 's of whtever else

me.someproperty  = somevalue

'Set the Value

Me.CurrentRow.Item("cki_Amount") = value

End Set


Andria Jensen
Andria Jensen
Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)Advanced StrataFrame User (600 reputation)
Group: Forum Members
Posts: 336, Visits: 497
I have several controls on a form, all with BindingField properties set on them.  When one changes, it affects the value of several others.  For example, I may have a Days field which affects the calculation of a Date2 field.  This would be something like Date2=Date1+Days.  When I type a value into the Days field I want it to update Date2 with whatever is in Date1 plus whatever I just typed into Days.

My question is how to best do this when binding to a BO field.  There seems to be some odd behavior in which it is struggling to know whether to use the data in the BO or the data in the field.  How do I make this work correctly??

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