Problem
I encountered this error whenever components.dispose() is called in a windows form with DataGridView.
The following exception occured in the DataGridView:
System.IndexOutOfRangeException: Index 0 does not have a value. at System.Windows.Forms.CurrencyManager.get_item(Int32 Index) at System.Windows.Forms.DataGridViewDataConnection.GetError(Int32 rowIndex)
To replace this default dialog please handle the DataError event.
Solution
My solution was calling DataGridView.dispose() method before components.dispose() is called as advised from here
Question
I'm still not sure why we need to call dispose method on DataGridView. If base.dispose() is called instead of components.dispose() and we don't call DataGridView.dispose(), this error wouldn't occur...which is logical as base.dispose() disposes everything.
Why doesn't components.dispose() call DataGridView.dispose()?