I have some code that selects the row clicked on. Previously it was called only on a right click in order to ensure that the correct row was selected before the context menu was updated and displayed, but now I need to ensure that the current row changes to prevent the wrong row data being dragged in drag and drop. Here is the code:
private void GridMouseDown(object sender, MouseEventArgs e)
// move cursor to clicked item
DataGridView.HitTestInfo info = grid.HitTest(e.X, e.Y);
if (info.Type == DataGridViewHitTestType.Cell)
grid.CurrentCell = grid[0, info.RowIndex];
At the click CurrentCell is 0,0. Testing the value of info.RowIndex prior to setting CurrentCell shows 6. After setting CurrentCell to [0,6] the value of CurrentCell is [4,5]!!
Can anyone suggest why, and what to do about it?