I have a user control with a combobox, and so I can edit its text as a property, I have the following code:
public ComboBox.ObjectCollection _OptionList {
get {
return OptionChoice.Items;
}
set {
for (int i = 0; i < value.Count; i++)
{
OptionChoice.Items.Add(value[i]);
}
}
}
is it possible to access this property of a combobox as a property of a user control? If so what am I doing wrong? It builds and runs, but when i click on the property in VS and add a item, the new item is System.Object and won’t let me change it…
As I read it, you merely want the same Items collection on your UserControl – acting as a pass-through for a specific combo box on the UserControl.
So tell the designer what type of list you expect it to be:
You don’t ever want a setter on a collection property. (Well, almost never).