数据网格中的KeyUp与EditOnEnter无法正常工作

时间:2021-09-29 20:35:59

I have DataGridView which EditMode is on EditOnEnter. in that case the KeyUP method doesn't work? if i want to have KeyUp i should set the EditMode in EditOnKeyStroke or EditOnKeyStrokeOrF2. I have set

我有DataGridView,EditMode在EditOnEnter上。在这种情况下,KeyUP方法不起作用?如果我想拥有KeyUp,我应该在EditOnKeyStroke或EditOnKeyStrokeOrF2中设置EditMode。我已经设定

   this.KeyPreview = true;

on Form Load but it doesn't work. how can i fire Key up in EditOnEnter?

在表单加载但它不起作用。我怎样才能在EditOnEnter中启动Key?

1 个解决方案

#1


0  

Use

    private void  YourDataGridView_KeyUp(object sender, KeyEventArgs e)
        {
            ---- Check Column Name is == Your Column Name
            ---- set the EditMode in EditOnKeyStroke or EditOnKeyStrokeOrF2
        }

I am giving this Example just because You was not Posted your DataGridView Codes.

我给出这个例子只是因为你没有发布你的DataGridView代码。

UPDATE : AS per Your Need those Events can be Use full...

更新:根据您的需要,这些事件可以使用完整...

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            MessageBox.Show(e.KeyChar.ToString ()); 
        }

        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            MessageBox.Show("dataGridView1_KeyUp" + e.KeyData );
        }

        private void dataGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            MessageBox.Show("dataGridView1_PreviewKeyDown" + e.KeyData);
        }

#1


0  

Use

    private void  YourDataGridView_KeyUp(object sender, KeyEventArgs e)
        {
            ---- Check Column Name is == Your Column Name
            ---- set the EditMode in EditOnKeyStroke or EditOnKeyStrokeOrF2
        }

I am giving this Example just because You was not Posted your DataGridView Codes.

我给出这个例子只是因为你没有发布你的DataGridView代码。

UPDATE : AS per Your Need those Events can be Use full...

更新:根据您的需要,这些事件可以使用完整...

        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            MessageBox.Show(e.KeyChar.ToString ()); 
        }

        private void dataGridView1_KeyUp(object sender, KeyEventArgs e)
        {
            MessageBox.Show("dataGridView1_KeyUp" + e.KeyData );
        }

        private void dataGridView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            MessageBox.Show("dataGridView1_PreviewKeyDown" + e.KeyData);
        }