-
Datagrid: Selected Cell
Hi,
I have a datagrid. I have some code to select the entire row if a cell is clicked on:
Code:
dataGrid1.Select(dataGrid1.CurrentCell.RowNumber);
When this fires, it does select the entire row, but it also leaves the cursor in the selected cell and the background colour changes and basically looks rubbish.
I cant think of a way to stop this - I want the behaviour to be the same as clicking on a row header (which I have hidden for this excercise).
Please can somebody help me???
Thanks,
DJ
-
Not sure i understand your problem, but here is how i select a row. If its not what you are looking for, please ignore this post.
Change the dgContact to your datagrid name, and paste this in your project.
Code:
private void dgContact_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
System.Drawing.Point pt = new Point(e.X, e.Y);
DataGrid.HitTestInfo hti = dgContact.HitTest(pt);
if(hti.Type == DataGrid.HitTestType.Cell)
{
dgContact.CurrentCell = new DataGridCell(hti.Row, hti.Column);
dgContact.Select(hti.Row);
}
}