In winform datagrid, How to find the datagridcell by mouse coodina

G

Guest

Hi there,
I have a problem needs help.

In a winform, I have a datagrid.

In Mouse move event, I can get coodinates of Mouse. I want to decide which
datagridcell my mouse is on. Can anybody tell me how to do it?

Thanks,

Karl
 
J

James Curran

Karl said:
In Mouse move event, I can get coodinates of Mouse. I want to decide
which datagridcell my mouse is on. Can anybody tell me how to do it?

private void datagrid_MouseHover(object sender, System.EventArgs e)
{
Point pt = this.PointToClient(Cursor.Position);
DataGrid.HitTestInfo myHitTest = datagrid.HitTest(pt);
int column = myHitTest.Column;
int row = myHitTest.Row;
// :
// :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top