Solved

DataGridView Question

Posted on 2006-06-24
6
637 Views
Last Modified: 2010-04-16
How to determine in which row and column of the datagridview the mouse pointer is in the datagridview mousedown event?
0
Comment
Question by:michellechan57
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 6

Expert Comment

by:MuhammadAdil
ID: 16974809
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
 

Author Comment

by:michellechan57
ID: 16974844
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
 

Author Comment

by:michellechan57
ID: 16975009
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
 
LVL 11

Expert Comment

by:Agarici
ID: 16982051
to get a refound post a request here:http://www.experts-exchange.com/Community_Support/

A.
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 17047263
Closed, 125 points refunded.

GhostMod
Community Support Moderator
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question