Index was out of range. Must be non-negative and less than the size of the collection. – On close form – DataGrid column
14-Jul-1414 Leave a comment
When closing a Windows Form on a button using Me.Close then get the following:
Error
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Solution
Tabs with Detail and List using a DataGridView, both
Had switched a BindingSource from a data table to a data source (object) which used a different field, so the DataGridView lookup column now had an invalid column.
Change to new column name and it will work.
End.