views:

365

answers:

1

Hello,

I hope that someone can help me with an issue related to binding a bindable collection class to one of the Winforms Telerik list controls.

If you bind to a plain ole windows list control like this...

dim list as new listBox

with list
    .DataSource=myCollectionClass  'this contains a collection of widgets.
    .ValueMember="WidgetID"
    .DisplayMember="WidgetName"
end with

I can then get a widget out of the list by doing this...

Dim myWidget as Widget=ctype(list.Items(0),Widget)

If you do the exact same code with for example a Telerik RadListBox (same example as above) but change line one to be

Dim list as new RadListBox.

With RadControls it seems you cannot cast to the Object type directly. Whenever I try this I get the following error...

Unable to cast object of type 'Telerik.WinControls.UI.RadListBoxItem' 
to type 'Widget'.

Can someone at the least confirm that this is a known limitation of Telerik RadControls for Winforms or let me know the proper way to do it.

Thanks. Any help will be appreciated. Any thoughts?

Seth

A: 

I also asked this question on the Telerik forum. Here is the answer I got...

"You can take the data bound item by the DataItem property that RadComboBoxItem exposes. For example:"

Me.Text = (CType((CType(Me.RadComboBox1.SelectedItem, RadComboBoxItem)).DataItem, Employee)).Phone

Seth

Seth Spearman