DataGridView Question

How to determine in which row and column of the datagridview the mouse pointer is in the datagridview mousedown event?
michellechan57Asked:
Who is Participating?
 
GhostModConnect With a Mentor Commented:
Closed, 125 points refunded.

GhostMod
Community Support Moderator
0
 
MuhammadAdilCommented:
Hi dear

see this sample code

private void myDataGridView_MouseDown(object sender, MouseEventArgs e)
        {
            int ColumnIndex =myDataGridView.SelectedColumns[0].Index;  // Selected Column Index
            int RowIndex = myDataGridView.SelectedRows[0].Index;  // Selected Row Index
        }

Regards

Adil
0
 
michellechan57Author Commented:
Hi

Thanks for responding.
The sample code returns the selected row and column.
I wanted to get the row and column at point (e.X,e.Y).
Any idea?
0
 
michellechan57Author Commented:
I managed to find a solution:

DataGridView.HitTestInfo myHit = dataGridView1.HitTest(e.X, e.Y);
if (myHit.Type == DataGridViewHitTestType.Cell)
{
    // select row == myHit.RowIndex;
}

Can I request for a refund?
0
 
AgariciCommented:
to get a refound post a request here:http://www.experts-exchange.com/Community_Support/

A.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.