Arrowkeys in datagrid

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


}
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
L

Lasse Edsvik

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


}
 
N

Nicholas Paldino [.NET/C# MVP]

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


}
 

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