selecting the entire row in a datagrid when the user clicks on a cell in the row

Posted on 2005-05-16
Last Modified: 2012-06-21
I have tried the code below but the entire row still isn't selected only the cell clicked on:

private void dataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
     System.Drawing.Point pt = new Point(e.X, e.Y);
     DataGrid.HitTestInfo hti = dataGrid1.HitTest(pt);
     if(hti.Type == DataGrid.HitTestType.Cell)
          dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
Question by:TerryBurger
    LVL 21

    Accepted Solution

    i had to do it in both mouse_down and mouse_up events


    Author Comment

    I tried doing it in both events and it still only selects the single cell.  I even tried putting dataGrid1.Select(1) in a button to see if that would work but that didn't select the first row like it should have? Is there a command I'm missing maybe?

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    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…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now