Hi,
I have a DataGridView with an underlying DataTable as the data source. Under certain circumstances, the DataGridView.CurrentCell is getting inexplicably changed.
If I edit the content of a cell, then click on a cell in the next row, there is a cascade of handled events involving both the grid and the DataTable. This includes, in order:
- dgv_MouseDown
- dgv_CellValidating
- dgv_ColumnChanging
- dgv_RowValidating
- dgv_CellEndEdit
- dt_RowChanged
- dgv_RowValidating (again)
- dgv_CurrentCellChanged
I think the first time dgv_RowValidating is called, it is for the row just edited, and the second time, I think it is for the new row. At the end of the second call to dgv_RowValidating, the value of CurrentCell.RowIndex is correctly set to 5. However, when it enters the dgv_CurrentCellChanged method, the CurrentCell.RowIndex has inexplicably changed to 10.
As far as I can tell, there is no code or other event handlers getting called between the two methods, yet the CurrentCell is different.
I suspect something to do with the native behavior of the DataGridView. Any clues would be very welcome.
Thanks.
Dan
There is a ton of code, so it is not really practical to post the code here.
Dan Hurwitz