【问题标题】:Infragistics Ultragrid - do not move below row when selecting right most columnInfragistics Ultragrid - 选择最右边的列时不要移动到行下方
【发布时间】:2020-09-10 09:13:35
【问题描述】:

在最后一列按右箭头键时,有什么方法可以强制 Infragistics Ultragrid 不移到行下方?

例如有下表,在具有“C”值(COL_1,第 1 行)的单元格中 - 如果我按右箭头键,它会将我移动到行下方(D 值),而我想留在同一行,同样单元格(当我到达行的“末尾”时)

   COL_A | COL_B | COL_C
1    A      B        C
2    D      ...

【问题讨论】:

    标签: c# infragistics ultrawingrid


    【解决方案1】:

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

    【讨论】:

    • 谢谢 - 这正是我想要的!
    【解决方案2】:

    网格中的导航是默认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));
    

    【讨论】:

    • 感谢您的回复 - 这有效,但只是部分有效 - 现在当我移动到最后一列然后再按一次右箭头键时,我正在关注下一个控件,而我想停在同一个单元格中(所以我可以按左箭头向后移动)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-24
    相关资源
    最近更新 更多