This is a migrated thread and some comments may be shown as answers.

Listbox - Error in Type Requirements for Items.Add()

1 Answer 41 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pawz
Top achievements
Rank 1
Pawz asked on 29 Jan 2008, 11:59 PM
In the rad list box, the Items.Add() function requires a variable of the type 'RadItem'. However, the following code crashes, with a 'Cannot convert RadItem to RadListBoxItem' error:

            foreach(string s in args) 
            { 
                RadItem item = new RadItem (); 
                item.Text = s; 
                radListBox1.Items.Add(item); 
            } 

Changing it to a RadListBoxItem instead of the standard RadItem works.

Just something to add to your todo list :)

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 01 Feb 2008, 04:21 PM
Hi Pawz,

Thank you for pointing this out for us. Indeed, adding anything but RadListBoxItem in the RadListBox.Items collection caused throwing such exception. We have already added refactored RadListBox (and respectively RadComboBox) to be capable of adding any descendants if RadItem. We will introduce this behavior in the upcoming Q3 2007 Service pack version, scheduled next week. Note that you will still not be able to add RadItem instances as this is a base class. Instead you should use descendants of this class.

Feel free to contact us if you have other questions.

Greetings,
Georgi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Pawz
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or