| | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 7:28:28 PM Posts: 1,148, Visits: 2,830 |
| | Based on the feedback from another post (http://forum.strataframe.net/FindPost13906.aspx) I was attempting to use OnValidate to update the data source. However, when I set this for a custom control I made, the set property never got fired (the data source was never updated). I implemented a property change event, but I'm thinking I must need a validate event also. What do I need to implement on this control to get OnValidate to work? |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 7:28:28 PM Posts: 1,148, Visits: 2,830 |
| | | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:13:06 AM Posts: 4,104, Visits: 4,176 |
| Well, this would depend on the control and property. If you are inheriting a textbox and using the Text property, the you wouldn't have a problem. You will have to fire the changed event of the property, and if one doesn't exists, then you need to create one.Public Property MyBindingProperty As String Get Return _MyBindingProperty End Get Set (Byval value as String) _MyBindingProperty = value OnMyBindingPropertyChanged() End Set End Property Public Event MyBindingPropertyChanged As EventHandler
Private Sub OnMyBindingPropertyChanged() RaiseEvent MyBindingPropertyChanged(Me, EventArgs.Empty) End Sub
This really shouldn't have anything to do with the IBusinessBindable, but rather the .NET binding that goes on behind the scenes one the SF binding creates the Binding class and adds it to the control. So it as though you are just manually binding the control to the property (you would have the same results). |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 7:28:28 PM Posts: 1,148, Visits: 2,830 |
| | Already done this. Works great....until I change the control to update the data source OnValidate, then the set on the property never gets called, therefore the OnChanged event never gets called, and the field in the BO is never updated. So the question is, what needs to happen here so I can use the OnValidate to update the BO? |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:13:06 AM Posts: 4,104, Visits: 4,176 |
| | This is a control level issue. I am not sure if this is a custom control or not and it also depends on the type of control in which you are inheriting. Validation in a textbox is invoked, for example, when you try to leave the field. So it calls the OnValidating method which raises the Validating event. This method call is never happening in your control. If you are inheriting the UserControl, then you could override the OnValidating and/or the OnValidated method and add your logic to force this to update. |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 11:13:06 AM Posts: 4,104, Visits: 4,176 |
| | One other thing. If you are inherited a control that already has the OnValidated method, then just call it within your control when you want the control to validate and the binding should follow suit. |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Yesterday @ 7:28:28 PM Posts: 1,148, Visits: 2,830 |
| I'll look into this. This is a sub classes TextControl, by implementing IBusinessBindable. I'll have to see if it has/raises the Validating event. It should be fun if it doesn't |
| |
|
|