Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
- {
- DataGridViewTextBoxCell cell = dataGridView1[2, e.RowIndex] as DataGridViewTextBoxCell;
- if (cell != null)
- {
- if (e.ColumnIndex == 4)
- {
- char[] chars = e.FormattedValue.ToString().ToCharArray();
- foreach (char c in chars)
- {
- if (char.IsDigit(c) == false)
- {
- MessageBox.Show("You have to enter digits only");
- e.Cancel = true;
- break;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment