开发者

C# DataGridView clean up

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 开发者_JAVA技巧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.


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.


Simple answer: no

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜