Guest User

Untitled

a guest
Jan 22nd, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  2. {
  3. DataGridViewTextBoxCell cell = dataGridView1[2, e.RowIndex] as DataGridViewTextBoxCell;
  4.  
  5. if (cell != null)
  6. {
  7. if (e.ColumnIndex == 4)
  8. {
  9. char[] chars = e.FormattedValue.ToString().ToCharArray();
  10. foreach (char c in chars)
  11. {
  12. if (char.IsDigit(c) == false)
  13. {
  14. MessageBox.Show("You have to enter digits only");
  15.  
  16. e.Cancel = true;
  17. break;
  18. }
  19. }
  20. }
  21. }
  22.  
  23.  
  24. }
Add Comment
Please, Sign In to add comment