custom user control with a devexpress imagecombobox


Author
Message
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
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
Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
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
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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

Fabian R Silva, -
Fabian R Silva, -
StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)StrataFrame User (267 reputation)
Group: StrataFrame Users
Posts: 153, Visits: 1.2K
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
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
LOL....no, no, no....VFP is a bad word around here anymore...so you just stick with it...you are doing great! Smile
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