ComboBox doesn't update from "ValueMember" when this property is changed on object

T

Teis Draiby

In order to show the names of the objects added to the ComboBox I've set:
sausageChooserCombo.ValueMember = "Name";

- but when I change the "Name"-property on the objects, the ComboBox does
not update accordingly - it still shows the initial names... I've tried
this:

comboBox1.Refresh();
comboBox1.Update();

The objects are added manually to the ComboBox like this:
comboBox1.Items.Add(newObject);

The DropDownStyle is set to "DropDownList".


Any help is appreciated,
Thanks, Teis
 
A

Alexander Shirshov

Teis,

I'm afraid what you want is only possible when combobox is *bound* to an
object implementing IBindingList. You'll need to add a collection class
which implement IBindingList and set DataSource property of a combobox to an
instance of this class.

The much simpler way is to give up your custom classes and use DataTable.

HTH,
Alexander
 
T

Teis Draiby

Alexander,
Thank you clarifying!

regards, Teis

Alexander Shirshov said:
Teis,

I'm afraid what you want is only possible when combobox is *bound* to an
object implementing IBindingList. You'll need to add a collection class
which implement IBindingList and set DataSource property of a combobox to an
instance of this class.

The much simpler way is to give up your custom classes and use DataTable.

HTH,
Alexander
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top