[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 648
  • Last Modified:

DataGridView Question

How to determine in which row and column of the datagridview the mouse pointer is in the datagridview mousedown event?
0
michellechan57
Asked:
michellechan57
1 Solution
 
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
 
GhostModCommented:
Closed, 125 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now