samedi 9 mai 2015

Windows ComboBox Selected Item (populated from List<>)

I am setting a combobox item like this:

List<Object> items = new List<Object>();
items.Add(new { Text = "MyVal", Value = 1 });
cbo.DataSource = items;

It then in VS returns:

enter image description here

But I cannot simply now say cbo.SelectedItem.Text or cbo.SelectedItem.Value. If i try this, I get the error

"object does not contain a definition for value and no extension method value 
accepting a first argument of type object could be found"

How can I get the Value Property please

Aucun commentaire:

Enregistrer un commentaire