Updating datasource in combobox

  • Thread starter Thread starter PeterB
  • Start date Start date
P

PeterB

Hi!

I have an arraylist (arr1) with objects (obj). The objects has a property
named p1, I have set the DataSource-property of a combobox (cmb1) to arr1,
and the DisplayMember property to p1.

If arr1 is filled before the "connection" all items are listed in cmb1, but
if I manipulate (add, remove, change) any objects in arr1, it isn't
reflected in cmb1. (i.e. if I add an object to arr1 it isn't shown in cmb1)

I have tried finding some kind of update method for this but can't seem to
find anything usefull. Do I need to re-set the DataSource binding? Do I need
to manually add the object to the arr1 AND the cmb1?

thanks in advance,

Peter
 
I found the anwer just after punching Ctrl+Enter.

You _can't_ update the arraylist and have it's changes show in the bound
combobox. The workaround would be to set the DataSource value to null and
the re-set it to the arraylist.

Does anyone know if this is something that will be changed in the upcoming
framework?

thanks,

Peter
 
The databound controls can only redisplay automatically contents if they are
bound to a data source that implements IBindingList and raises ListChanged
events. Naturally, ArrayList does neither. You can derive your own class
that would have this functionality
 
Back
Top