Reputation: 10825
Is there any way to force Infragistics Ultragrid to do not move below row when pressing right arrow key on last column ?
eg having below table, being in cell with "C" value (COL_1, row 1) - if I press right arrow key it moves me to below row (D value), while I woudld like stay in same row, same cell (as Ive reached 'end' of row)
COL_A | COL_B | COL_C
1 A B C
2 D ...
Upvotes: 2
Views: 468
Reputation: 8935
The KeyDown
event for the UltraGrid might be used to implement this functionality too:
private void ultraGrid1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Right && sender is UltraGrid ug)
{
if ((ug.CurrentState & UltraGridState.CellLast) == UltraGridState.CellLast)
e.Handled = true;
}
}
Upvotes: 1
Reputation: 2120
Navigation in the grid is a result of default KyeActionMapping. What you can do is remove mapping for Right and add a new one preventing last cell state like this:
// Get the mappings related to Right key and remove them from KeyActionMappings
var mappings = this.ultraGrid1.KeyActionMappings.GetActionMappings(Keys.Right, 1, 0);
foreach (var mapping in mappings)
{
this.ultraGrid1.KeyActionMappings.Remove(mapping);
}
// Add new KeyActionMappings
this.ultraGrid1.KeyActionMappings.Add(
new GridKeyActionMapping(
Keys.Right,
UltraGridAction.NextCell,
UltraGridState.CellLast,
UltraGridState.Cell,
SpecialKeys.AltCtrl,
0,
true));
Upvotes: 1