.Net DataGridView "Index 0 does not have a value."
Posted
by Ben
on Stack Overflow
See other posts from Stack Overflow
or by Ben
Published on 2009-10-27T11:30:06Z
Indexed on
2010/04/28
14:23 UTC
Read the original article
Hit count: 4494
I am having trouble with a DataGridView. I have a collection of 3 Items bound to the grid, when trying to delete one of the items and reload the grid.
If have code of
If (dlg.ShowDialog() = DialogResult.OK) Then
'Show dialog with grid on it
End If
On the opened dialog, I delete an item from the grid (which should in turn, delete the item from the collection, and re-load the grid), and it returns to the "If (dlg.show..." line, with the error of
"A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Windows.Forms.dll
Additional information: Index 2 does not have a value. "
(I have break into debugger set on for common language runtime errors)
I can understand this error if i were trying to access any cells, row or columns, but im not, and then I would expect the exception to stop on the line of code that is trying to access this grid data, not the "If (dlg.ShowDialog()... " line
Any ideas? Cheers
© Stack Overflow or respective owner