Solved

DataGridView Question

Posted on 2006-06-24
6
636 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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