OT: Binding

OT: Binding

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


whelzer posted on Tuesday, October 07, 2008

Is there a general rule of thumb with binding.  Eg  I need to set a object value at runtime on the UI.

Should I set the value directly _myObject.Value = 123 or set it in the bound textbox txtValue = 123.


triplea replied on Tuesday, October 07, 2008

That sounds like a business rule to me in which case it should be placed within OnPropertyChanged or whatever trigger point within the BO.

whelzer replied on Tuesday, October 07, 2008

I wasn't convinced at all it was a business rule but the more I think about it, it definitely is.
Situation is thus...

Users pushes button (Create) on form1

A Form 2 opens and calls its DoNew - which calls _myobject.GetNewObject()

I just happen to "know" some of the values (not at all times) for _myObject and wanted to get them on screen form2 is displayed.

I "think" I've decided to overload GetNewObject() as it will give me a lot of flexibility.
in the future.

ajj3085 replied on Tuesday, October 07, 2008

Is the value changing because another property on the BO changes? If so, you may want to implement that in your BO.  If not... I'm not sure, it's never come up. 

If you set it via the BO, you might need a BindingSourceRefersh component, otherwise your UI may not display the new value, due to how databinding works.

Copyright (c) Marimer LLC