//La form KeyPreview = true; KeyPress += new KeyPressEventHandler(Form1_KeyPress); //La datagridview dataGridView1.CellEndEdit += new DataGridViewCellEventHandler(dataGridView1_CellEndEdit); dataGridView1.CellContentClick += new DataGridViewCellEventHandler(dataGridView1_CellContentClick); bool CellEditing = false; private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { CellEditing = true; } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { CellEditing = false; } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { if (CellEditing) { if (!char.IsDigit(e.KeyChar) && !(e.KeyChar.ToString().Equals("\b"))) e.Handled true; //n'affiche pas etfalse => affiche else { e.Handled = false; } // Si la touche Entrez doit jouer le rôle de tabulation, ajoutez le code suivant if (e.KeyChar == 13) { SendKeys.Send("{TAB}"); } } }