Datagrid CurrentCellChanged

  • Thread starter Thread starter Lasse Edsvik
  • Start date Start date
L

Lasse Edsvik

Hello

Im trying to select current row in a datagrid if a user clicks it or uses
the arrowkeys to navigate in a datagrid.

i had this in MouseUp event but i need something else for CurrentCellChanged
event...... not sure what

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);


}
 
hmm..

dataGrid1.Select(dataGrid1.CurrentCell.RowNumber);



"works", but it shows current cell as grey with cursor and the value is
selected :(
 
Dmitriy,

yes, ive tried that, still the current shell shows up as grey and text is
selected and cursor is right infront of it...... if you hold down your
mousebutton you'll see it since it uses the mouseup event. And if you use
the arrowkeys it shows too

/Lasse




Dmitriy Lapshin said:
Lasse,

Check out the Windows Forms FAQ on http://www.syncfusion.com. It has an
article on how to select whole rows when the user clicks on a cell.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Lasse Edsvik said:
Hello

Im trying to select current row in a datagrid if a user clicks it or uses
the arrowkeys to navigate in a datagrid.

i had this in MouseUp event but i need something else for CurrentCellChanged
event...... not sure what

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);


}
 
Back
Top