Datagrid Question

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??
 
P

Pete Davis

Try replacing:

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


with

{
dataGrid1.Select(hti.Row);
}
 
J

JSheble

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??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top