How do I refresh a ComboBox who has ArrayList as Datasource?

G

Guest

I have a ComboBox on my form, and I set it's DataSource to an ArrayList of
custom objects. Everything loads fine, all the entries I initially loaded
into the ArrayList appear in my ComboBox.

However, while my program is running and I add a new object to that
ArrayList - this ComboBox is not updating to reflect the change.

I have gone so far as to try:

clientList.Invalidate();
clientList.DataSource = RecordKeeper.RecordList;
clientList.Refresh();

all at once in that order.

and still can't get the ComboBox to refresh...

how do I do this?
 
P

Patrick Steele

I have a ComboBox on my form, and I set it's DataSource to an ArrayList of
custom objects. Everything loads fine, all the entries I initially loaded
into the ArrayList appear in my ComboBox.

However, while my program is running and I add a new object to that
ArrayList - this ComboBox is not updating to reflect the change.

I have gone so far as to try:

clientList.Invalidate();
clientList.DataSource = RecordKeeper.RecordList;
clientList.Refresh();

all at once in that order.

I think the easiest way is to "unbind" the combobox and then "rebind"
it. It probably has some internal "smarts" to not rebind if you set the
DataSource equal to the DataSource it's already bound to:

ClientList.DataSource = null;
ClientList.DataSource = RecordKeeper.RecordList;
 

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