ListBox DataSource

  • Thread starter Thread starter Igor Vrdoljak
  • Start date Start date
I

Igor Vrdoljak

Hi.

I am binding ListBox control to ArrayList of custom objects. This works
fine if I do not change ArrayList in runtime. The problem is that if I
do change the ArrayList, nothing happens with ListBox.

The only workaround I managed to find is setting DataSource to null and
then back to (changed) ArrayList. This seems a bit wrong, so if anyone
knows of a better way, I would be grateful for any help.

Igor
 
Hi.
I am binding ListBox control to ArrayList of custom objects. This works
fine if I do not change ArrayList in runtime. The problem is that if I
do change the ArrayList, nothing happens with ListBox.

The only workaround I managed to find is setting DataSource to null and
then back to (changed) ArrayList. This seems a bit wrong, so if anyone
knows of a better way, I would be grateful for any help.

Calling Refresh on the CurrencyManager should force updates from an ArrayList to appear in your listbox. You can obtain the CurrencyManager by casting the BindingManagerBase object returned by indexing the BindingContext with your DataSource i.e.
ArrayList dataSource = new ArrayList() ;
.... do some stuff

CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[dataSource];
myCurrencyManager.Refresh();

HTH,
Ian Cooper
www.dnug.org.uk
 
Back
Top