Infragistics Ultragrid - 选择最右边的列时不要移动到行下方
Infragistics Ultragrid - do not move below row when selecting right most column
有什么方法可以强制 Infragistics Ultragrid 在最后一列上按右箭头键时不移动到行下方?
例如低于 table,位于具有“C”值的单元格中(COL_1,第 1 行)- 如果我按向右箭头键,它会将我移动到下面的行(D 值),虽然我想留在同一行,同一单元格(当我到达行的 'end' 时)
COL_A | COL_B | COL_C
1 A B C
2 D ...
网格中的导航是默认 KyeActionMapping 的结果。你可以做的是删除 Right 的映射并添加一个新的映射来防止像这样的最后一个单元格状态:
// 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));
UltraGrid 的 KeyDown
事件也可用于实现此功能:
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;
}
}
有什么方法可以强制 Infragistics Ultragrid 在最后一列上按右箭头键时不移动到行下方?
例如低于 table,位于具有“C”值的单元格中(COL_1,第 1 行)- 如果我按向右箭头键,它会将我移动到下面的行(D 值),虽然我想留在同一行,同一单元格(当我到达行的 'end' 时)
COL_A | COL_B | COL_C
1 A B C
2 D ...
网格中的导航是默认 KyeActionMapping 的结果。你可以做的是删除 Right 的映射并添加一个新的映射来防止像这样的最后一个单元格状态:
// 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));
UltraGrid 的 KeyDown
事件也可用于实现此功能:
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;
}
}