Why HitTest does not work in DragOver in DataGridView

DataGridView:

I use the following code to highlight the selected record when the dragOver event is triggered. I work properly in MouseMove event.

DataGridView.HitTestInfo hit = dgvOperation.HitTest(e.X, e.Y);
if (hit.Type == DataGridViewHitTestType.Cell)
{
MessageBox.Show(dgv.Rows[hit.RowIndex].Index.ToString());
dgvOperation.Rows[hit.RowIndex].Selected = true;
}

When I apply the above code in the DragOver event, I cannot get the RowIndex from the DataGridView,Why?

Or who got other solution to provide the same function?

Thanks

[592 byte] By [Clement_kflee] at [2007-12-22]
# 1
you have to compute the location of the specified screen point into client coordinates, like so

Point p = dgvOperation.PointToClient(new Point(e.X, e.Y));

DataGridView.HitTestInfo hit = dgvOperation.HitTest(p.X, p.Y);
if (hit.Type == DataGridViewHitTestType.Cell)
{
MessageBox.Show(dgv.Rows[hit.RowIndex].Index.ToString());
dgvOperation.Rows[hit.RowIndex].Selected = true;
}

swaza at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...