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


How to get changes to a property on a control to update BO when using...
Author
Message
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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?
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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!
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yep, its all clear now. BigGrin And its working w00t
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