Arrowkeys in datagrid

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

Lasse Edsvik

Hello

I was wondering if there is a way to select a row in a datagrid if you
navigate in it using arrowkeys.

i have this onMouseUp, should do the same with arrowkeys:

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


}
 
Lasse,

Instead of using the mouse up event, and the key up or key down event,
why not detect when the cell has changed? When the cell changes, just
select the full row that the cell is in. This would handle both keyboard
and mouse changes.

Hope this helps.
 
Nicholas,

hmm, is there an OnChange event or something like that?

/Lasse


Nicholas Paldino said:
Lasse,

Instead of using the mouse up event, and the key up or key down event,
why not detect when the cell has changed? When the cell changes, just
select the full row that the cell is in. This would handle both keyboard
and mouse changes.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lasse Edsvik said:
Hello

I was wondering if there is a way to select a row in a datagrid if you
navigate in it using arrowkeys.

i have this onMouseUp, should do the same with arrowkeys:

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


}
 
Lasse,

Yes, it does. The CurrentCellChanged event is what you want to
subscribe to.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lasse Edsvik said:
Nicholas,

hmm, is there an OnChange event or something like that?

/Lasse


message news:OYtdt%[email protected]...
Lasse,

Instead of using the mouse up event, and the key up or key down event,
why not detect when the cell has changed? When the cell changes, just
select the full row that the cell is in. This would handle both keyboard
and mouse changes.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Lasse Edsvik said:
Hello

I was wondering if there is a way to select a row in a datagrid if you
navigate in it using arrowkeys.

i have this onMouseUp, should do the same with arrowkeys:

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