private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { e.Control.KeyPress -= new KeyPressEventHandler(polNoDataGridViewTextBoxColumn_KeyPress); if (dataGridView1.CurrentCell.ColumnIndex == 3) //Desired Column { TextBox tb = e.Control as TextBox; if (tb != null) { tb.KeyPress += new KeyPressEventHandler(polNoDataGridViewTextBoxColumn_KeyPress); } } } private void polNoDataGridViewTextBoxColumn_KeyPress(object sender, KeyPressEventArgs e) { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)) { e.Handled = true; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)