StrataFrame Forum

How to get changes to a property on a control to update BO when using IBusinessBindable

http://forum.strataframe.net/Topic8978.aspx

By Greg McGuffey - 5/22/2007

I'm still not understanding how to get SF to update data if I add the IBusinessBindable interface to a control. My initial understanding was that I needed an event that changed after the bound property changed. I.e. if my control had a property called MyProperty that I wanted to be bindable (i.e. the property would be loaded with data by the BO and changes to the property would update the BO), I'd need a MyPropertyChanged event:



' The property that can be bound via SF

Private _myProperty As Integer

Public Property MyProperty() As Integer

Get

Return _myProperty

End Get

Set(value As Integer)

_myProperty = value

Me.OnMyPropertyChanged()

End Set

End Property



' The event that occurs after the property is changed

Public Event MyPropertyChanged As EventHandler

Protected Overridable Sub OnMyPropertyChanged(e As EventArgs)

Raiseevent MyPropertyChanged(Me,e)

End Sub




However, this didn't work. Sad



Next I noticed that in the SF RichTextbox, you implemented the INotifyPropertyChanged interface, so I tried that. I created an event called PropertyChanged and raise that event in the set of any properties I want to be bindable. Again it didn't update the BO.



How do I get the BO to know when the property changes, so it updates itself with the new data?
By Greg McGuffey - 5/22/2007

I found the problem I was having. The control was never firing either the [property]Changed event or the PropertyChanged event because I wasn't bubbling the required event up from the base control. Now BOTH of the methods outlined in the original post work. Blush



Hope this helps somebody else!
By StrataFrame Team - 5/23/2007

Hehe, yes, you'll have to bubble the event up for it to work.  However, you only need to create the event if you're creating a custom property.  For instance, we inherited TextBox and since it already had a TextChanged event, we didn't have to create a new one since we didn't define the Text property.

So, only when you define the property do you need to handle the changed events yourself.  Hope that helps.

By Greg McGuffey - 5/23/2007

Yep, its all clear now. BigGrin And its working w00t