Datagrid not updating

  • Thread starter Thread starter Sanji
  • Start date Start date
S

Sanji

I've made an ArrayList of custom objects the datasource of my datagrid
but when I remove an object from the ArrayList, the datagrid still
displays the object. I've watched the datagrid.datasource object in
the debugger and you can see the object from the ArrayList removed.
Has anyone ever run into this?
 
DataGrid has no way to know ArrayList has been changed outside as ArrayList
has no events grid can subscribe to.
Try calling Update() method of the grid after ArrayList has been changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
I've tried calling the Update() method with no luck. Would it make
any difference if I bind the arraylist using the datagrid's
databinding method instead of setting the datasource property to my
arraylist?
 
No, it won't help.



Sounds like you have no choice but to unbind array list from the grid by
setting DataSource to null and bind it back.

That would force grid to reload data from ArrayList.

You could also consider using advanced data sources like DataTable which
supports change notification.

Another option would be to extend ArrayList by implementing IBindingList
interface.



Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.



Sanji said:
I've tried calling the Update() method with no luck. Would it make
any difference if I bind the arraylist using the datagrid's
databinding method instead of setting the datasource property to my
arraylist?




(e-mail address removed) ("Ilya Tumanov [MS]") wrote in message
DataGrid has no way to know ArrayList has been changed outside as
ArrayList
has no events grid can subscribe to.
Try calling Update() method of the grid after ArrayList has been changed.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
 
Back
Top