[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get selected row index when mouse dbl click on any cell row

Posted on 2007-10-19
3
Medium Priority
?
795 Views
Last Modified: 2013-12-17
Hi All,

I am working on Visual c# 2.0 application, i have form with DataGridiew that displays data from db,, and i want the user if double click on any row on grid get the index of that column?? how can i do that?

Iam new to desktop app programming so i appreciate any help on this?
0
Comment
Question by:Abu Hamdan
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 20109830
Something like this:

        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                DataGridView.HitTestInfo hitTest = this.dataGridView1.HitTest(e.X, e.Y);

                if (hitTest != null && hitTest.RowIndex != -1 && hitTest.ColumnIndex != -1)
                {

                }
            }
        }

Bob
0
 
LVL 22

Expert Comment

by:JimBrandley
ID: 20109852
Do you want the row index, or the column index?
Add an event handler for the RowHeaderMouseDoubleClick event if you want the row.
Add an event handler for OnSelectionChanged event if you want the column.

Jim
0
 
LVL 7

Author Comment

by:Abu Hamdan
ID: 20109919
thanks Bob,, its exatly what i wanted :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month17 days, 18 hours left to enroll

829 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