Windows form application exception
I'm guessing that you have bound a List that is initially empty, (or other sort of collection that does not generate list changed events) to your DataGridView
, and then added items to this List.
The items you add will display correctly on your grid, but clicking on a row will cause this exception. This is because the underlying CurrencyManager
will be reporting its current row position as an offset of -1. It will stay this way because the List does not report changes to the grid.
You should only bind your list to the grid if it has some items in it to begin with, or rebind when you add them.
See also my answer to this question, which is essentially the same problem.