private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["int1"].Index) //this is numeric column { int i; if (!int.TryParse(Convert.ToString(e.FormattedValue), out i)) { e.Cancel = true; MessageBox.Show("must be numeric"); } }
MessageBox.Show
DataGridView
MaskedTextBox
private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar >= 48 && e.KeyChar <= 57) { e.Handled = true; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)