Sep 24 2009

get object out of telerik radcontrol for winforms binding

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