How to update ComboBox/ListBox bound to ArrayList?
-
I have a ComboBox that has the DataSource property set to an ArrayList. I am using the following code to force the ComboBox to update when I make changes to the ArrayList: this.cboTrains.DataSource = null; this.cboTrains.DataSource = alTrains; this.cboTrains.DisplayMember = "Name"; Is there a better way? Also have the same issue with ListBox. Thanks. www.lovethosetrains.com
-
I have a ComboBox that has the DataSource property set to an ArrayList. I am using the following code to force the ComboBox to update when I make changes to the ArrayList: this.cboTrains.DataSource = null; this.cboTrains.DataSource = alTrains; this.cboTrains.DisplayMember = "Name"; Is there a better way? Also have the same issue with ListBox. Thanks. www.lovethosetrains.com
Try calling the "Refresh" method on the comboBox to make it update instead of resetting its data source...
-
Try calling the "Refresh" method on the comboBox to make it update instead of resetting its data source...
Nope.. Doesn't do the trick. The Refresh method just forces the control to redraw (not update what it knows).. I was thinking of adding an event that fires when the ArrayList is changed and entending the control (ListBox/ComboBox) to have a new method that updates the bindings. I'm just not wanting to overly complicate it (or do more work then needed). Thanks. www.lovethosetrains.com