Click here to Skip to main content
14,453,689 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to capture the cell's keypress event in datagridview.
i am using following code, but by this code Enter/Down keys are not capturing.

void dataGridView1_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
        {
            TextBox txtbox = e.Control as TextBox;
            if (txtbox != null)
            {
                txtbox.KeyPress += new
KeyPressEventHandler(txtbox_KeyPress);
            }
        }

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


What to do for capturing Enter/Down/Up key in the cell of data grid view?
Please Help
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 2

Use PreviewKeyDown event instead of Keypress event.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100