Datagrid CurrentCellChanged

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


}
 
L

Lasse Edsvik

hmm..

dataGrid1.Select(dataGrid1.CurrentCell.RowNumber);



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

Lasse Edsvik

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


}
 

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