StrataFrame Forum

custom user control with a devexpress imagecombobox

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

By Fabian R Silva, - - 5/19/2008

I have a table on my db with some png icons to fill a devex imagecombobox like this:



ID / ICONNAME / IconData (varbinary(max))





I created a user control that fill a internal imagelist from this table (via a "IconBO") and then add items to a imagecombobox (that can't support a datasource), the value of the items on the combo are the id of the icon, all ok from now.



I see how you implemented the IBusinessBindable and IInitializeBusinessObject on datetimepicker and try to do something similar, I created a property "BindableValue" on mysf user control and on this I put on the get /set:



Get

Return CInt(ComboIcon.EditValue)

End Get

Set(ByVal value As Integer)



If Me._InValueSet Then

Exit Property

Else

Me._InValueSet = True

End If



value = CInt(ComboIcon.EditValue)



Me._InValueSet = False

End Set



the problem is that the combo get the id from the property ok, but when I edit the form, change the value on the combo and try to save it, If I see the "BindableValue" property, this reflect the id (example: 9 (integer)), but on the inmediate window I put trycast(me.Parentform,MyTestForm).PrimaryBusinessObject("IconID") (that is the id of my icon) and I get an "1" (integer) value, I not sure what I made wrong that I cannot set the id from the property automatically.



I not known too much about databinding and sure I made something wrong, but not sure what I have to see or learn to made it to work ok.



Thanks for the great support Smile



- Fabian
By Fabian R Silva, - - 5/19/2008

sorry I misstyped something where say " value = CInt(ComboIcon.EditValue)" I have to write

comboIcon.EditValue = Value



sorry for this, thinking to write in english I forgive to write correctly the problem w00t
By Trent L. Taylor - 5/21/2008

More than likely your problem is that you are not calling a "changed" event which notifies the binding of a change in the value of the bound property.  Since you have a property called BindableValue, you will want to create a BindableValueChanged event and an OnBindableValueChanged method to call the event.  You will then place this in the Set (or anyplace you change the internal value and want to update the bound value).

Public Event BindableValueChanged as Eventhandler

Protected Overridable Sub OnBindableValueChanged()
    RaiseEvent BindableValueChanged(Me, EventArgs.Empty)
End Sub

Next, you will want to call the OnBindableValueChanged method when the value changes within the control:

Public Property BindableValue As Integer
    Get
        Return _BindableValue
    End Get
    Set(Byval value As Integer)
        _BindableValue = value
        OnBindableValueChanged()
    End Set
End Property
By Fabian R Silva, - - 5/21/2008

I will try this, thanks Trent for give me some insight about this, I thinked that the event OnBindableValueChanged was used to intercept the change of this for the developer, not to say "the property has changed, change/refresh the BO data" (I thinked that it was automated knowed that when property change, the bind change it automatically) Blush



thanks again Trent, withtout your help I not sure if I can today encourage to program on .net and leave vfp back Smile
By Trent L. Taylor - 5/21/2008

LOL....no, no, no....VFP is a bad word around here anymore...so you just stick with it...you are doing great! Smile