IList being updated and telling bound controlls

  • Thread starter Thread starter Jakob Nielsen
  • Start date Start date
J

Jakob Nielsen

I have implemented a container class with IList and bound it to a listbox.
Works just fine, but if i then add a new item to my list, the listbox is not
updated.

Looking at the definition for IList it is clear that it does not have any
events to tell the bound controlls about changes, but can it really be that
after adding to the list I allways have to call an update method for the
listbox? I would rather have designed the interface to allow bound controlls
to get an event and then do an update on their own.

As a side note.. I am doing the change from c++ to c#, so i would like to
add a very basic question which I cant find the answer to... how exactly
_do_ you update a listbox when the data changes? There are many update,
refresh and invalidates, but they all seem to relate to a repaint.. not a
re-load list.
 
Jakob:

I believe a data source has to implement the IBindingList interface in
order for the control to automatically update.

If you have an IList source, you could just re-assign the DataSource
property of the bound control to the list and it will reload from
scratch. Of course, this can become expensive on big collections with
lots of changes, but I imagine that is why classes like the DataView
implement IBindingList.

HTH,
 
Back
Top