views:

305

answers:

2

I have a BindingList which is the data source for a Bindingsource, which in turn is a data source for a DataGridView.

(The objects are purely managed, and do not have anything that requires calling .Dispose().)

When I wish to clear the list, and hence clear the grid, I am simply calling BindingSource.Clear(), which as far as I can tell clears the underlying BindingList containing my objects, and because it is data-bound to the grid, the rows in the grid disappear.

Should I be doing anything else to the grid (or anything else), to ensure that all the data has been cleaned up?

Thanks.

+1  A: 

Simple answer: no

However, if anything else holds references to the objects in the BindingList then the GC would not collect them.

Tom Frey
+1  A: 

No, you don't need to. Just make sure you clear the binding source. As soon all references to the List are out of scope it will be garabge collected on the next collection cycle.

Johannes Rudolph