DataGridViewTextBoxColumn选项卡键行为

时间:2014-10-16 21:59:04

标签: c# datagridview keypress eventargs

我有DataGridView来组织学生的积分。选中后,我可以通过DataGridViewTextBoxColumn输入点数。 (蓝色细胞)。

enter image description here

我使用以下代码来控制输入是否为数字。

    private void dgwPNotlar_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)    
    {
        e.Control.KeyPress += new KeyPressEventHandler(CheckKey);
    }

    private void CheckKey(object sender, KeyPressEventArgs e)
    {
        if (!char.IsControl(e.KeyChar)
            && !char.IsDigit(e.KeyChar)
            && e.KeyChar != 'G' && e.KeyChar !='M'&&e.KeyChar!='g'&&e.KeyChar!='m')
        {
            e.Handled = true;
        }
    }

我想要的是当我完成向当前单元格输入点数时,TAB键将把我带到下一个学生点单元格。我尝试实现控制上面按下的键的代码,但是当我按TAB键时不会触发CheckKey方法。

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我认为你必须插入" CellEndEdit"来自DataGridView属性的事件!

通过此活动,您可以按" TAB"," ENTER"或你想要的每个按钮。

我希望这会对你有所帮助。