All I'm really trying to do is populate three different comboboxes with the same item. When this code executes below only one combobox is getting the values. Any help is welcomed. Thanks!
for (int i = 0; i < 100; i++)
{
RadComboBoxItem li = new RadComboBoxItem();
li.Text = i.ToString();
li.Value = i.ToString();
InputPairThousandValueComboBox.Items.Add(li);
InputUsertThousdandValueComboBox.Items.Add(li);
InputCurrentlyListedThousdandComboBox.Items.Add(li);
}
I couldn't find anything in the Telerik docs that says this explicitly, but it appears a single instance of a RadComboBoxItem
can only be contained in a single RadComboBox
; you can't share a RadComboBoxItem
between controls.
The docs do hint to this: the RadComboBoxItem
has an 'owner' property that is a reference to the RadComboBox
that contains the item (implying that there can be only 1 owner)
Under the covers, the second & third Add(...)
calls most likely first remove the item from the combo box its already in.
So, you'll have to create a separate RadComboBoxItem
for each RadComboBox
. Here's one way you could do it using the RadComboBoxItem
constructor that takes the text and value as arguments.
for (int i = 0; i < 100; i++)
{
var val = i.ToString();
InputPairThousandValueComboBox.Items.Add(new RadComboBoxItem(val, val));
InputUsertThousdandValueComboBox.Items.Add(new RadComboBoxItem(val, val));
InputCurrentlyListedThousdandComboBox.Items.Add(new RadComboBoxItem(val, val));
}