IList being updated and telling bound controlls

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.
 
S

Scott Allen

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top