Why you should always dispose DataGridViews
Because your application can crash otherwise, that’s why. While it’s always a good idea to explicitly dispose everything that is disposable, we can usually get away without disposing UI controls because a. Complex controls aren’t created often – a single instance is often reused. b. The finalizer kicks in and saves the day. If you’re creating multiple instances of a System.Windows.Forms.DataGridView, however, watch out, because (b) doesn’t happen at all if you don’t call Dispose or otherwise cause the control to be destroyed. When debugging a software crash dump recently, I found that the crash occurred because there was an … Continue reading Why you should always dispose DataGridViews