I hope you got this by now, but you seem to have re-invented the wheel. Why
don't you just the KeyValuePair object, instead. Even if you're doing
something fancy with your SelectionItem, you can pass it to the list of
KeyValuePair objects and easily load the combo box.
Otherwise, it could have something to with setting DisplayMember and
ValueMember properties before setting the DataSource property on the combo
box, which might reset those properties.
Good luck,
"Demetri" <(E-Mail Removed)> wrote in message
news:F68074A9-26D5-48A0-A3EC-(E-Mail Removed)...
> I have a structure called SelectionItem and it has two properties - Key&
> Value. I also have a combobox with the DisplayMember = Value and
> ValueMember
> = Key. I have the following simple code:
>
> List<SelectionItem> list = new List<SelectionItem>();
> list.Add(new SelectionItem(0, "Item1"));
> list.Add(new SelectionItem(1, "Item2"));
> myCboBox.DataSource = list;
>
> My issue is that during runtime the cbobox doesn't have Item1, Item2 as
> possible values. Rather it has the type name of the object (i.e.
> MyApp.UI.Forms.SelectionItem) for each item.
>
> What am I doing wrong?
|