Datagrid Question

  • Thread starter Thread starter Islamegy
  • Start date Start date
I

Islamegy

in my app i need to select Whole row (Blue) when i press any cell.. i found
and tried the following code but no luck

private void dataGrid1_MouseDown(object sender,
System.Windows.Forms.MouseEventArgs e)
{
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();
}

How could i select the Whole row on click like in web grid??
 
Try replacing:

{
dataGrid1.CurrentCell = new DataGridCell(hti.Row, hti.Column);
dataGrid1.Select();
}


with

{
dataGrid1.Select(hti.Row);
}
 
I've tried doing something similiar to this, and it does select (hilight)
the whole row, but it also makes the current cell I'm in look out of place
because the content of the cell itserlf is selected as well, thus leaving
the rest of the background of the current cell un-selected...

is there away around this??
 
Back
Top