468,537 Members | 1,735 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

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

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?
Oct 5 '06 #1
1 17051
In article <2B**********************************@microsoft.co m>,
Mr******@discussions.microsoft.com says...
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;

--
Patrick Steele
http://weblogs.asp.net/psteele
Oct 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Bruce D | last post: by
1 post views Thread by Bruce D | last post: by
2 posts views Thread by AMDRIT | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.