我正在使用infragistics Ultrawingrid v9.1。我想允许用户在单元格中输入数值数据,请按 进入 然后像您在Excel中看到的那样,将重点放在下面的单元格上。看来,关键事件可能比为此的关键事件要好,但是我一直在抛出一个例外,即使我从完整的网格的顶部开始,我也超越了超快瑞士的界限。这是我尝试过的代码:

    private void ugrid_KeyUp(object sender, KeyEventArgs e)
    {
        UltraGrid grid = (UltraGrid)sender;

        if (e.KeyCode == Keys.Enter)
        {
            // Go down one row
            UltraGridCell cell = grid.ActiveCell;
            int currentRow = grid.ActiveRow.Index;
            int col = cell.Column.Index;
            grid.Rows[currentRow + 1].Cells[grid.ActiveCell].Activate();
        }
    }

我希望这将使单元格在同一列中,但下面的一排将成为带有呼叫的活动单元格。

而是抛出了一个例外:

类型“ System.IndexOutoFrangeException”类型的例外发生在infragistics2.shared.v9.1.dll中,但在用户代码中未处理其他信息:索引不在数组的范围之外。

由于我在第0行,并且第1行1这对我来说是一个惊喜。电流和col的值分别为0和28。什么是更好的方法?顺便说一句,我可以再次执行此操作,下面的单元格,其中值为Currathrow = 1且col = 28。抛出了相同的例外。

有帮助吗?

解决方案

有人回答了我关于侵犯的问题...

    private void ugrid_KeyUp(object sender, KeyEventArgs e)
    {
        var grid = (UltraGrid)sender;

        if (e.KeyCode == Keys.Enter)
        {
            // Go down one row
            grid.PerformAction(UltraGridAction.BelowCell);
        }
    }

其他提示

我不知道我说的是对v9.1是否有效,但您也可以做这样的事情:

yourGrid.KeyActionMappings.Add(new GridKeyActionMapping(Keys.Enter, UltraGridAction.BelowCell, 0, UltraGridState.Row, SpecialKeys.All, 0));
 private void ulGrvProducts_KeyUp(object sender, KeyEventArgs e)
        {

            UltraGrid grid =  (UltraGrid)sender;

            if (e.KeyCode == Keys.Enter)
            {
                 //Go down one row
                grid.PerformAction(UltraGridAction.BelowCell);
            }
        }

使用后 grid.PerformAction(UltraGridAction.BelowCell) ,活动行会更改,但下一个单元格不在编辑模式下。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top