Link to home
Start Free TrialLog in
Avatar of TerryBurger
TerryBurger

asked on

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

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);
 
          dataGrid1.Select(hti.Row);
 
     }
 
}
 
ASKER CERTIFIED SOLUTION
Avatar of Yurich
Yurich
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TerryBurger
TerryBurger

ASKER

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?