private void dataGridView5_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
switch(e.ColumnIndex)
{
case 2:
DataGridViewCell currentCell = dataGridView5[e.ColumnIndex, e.RowIndex];
currentCell.ErrorText = "";
int x;
if ( int.TryParse(currentCell.Value.ToString(),out x) )
{
if (x == 0)
{
currentCell.ErrorText = "Value should not be zero";
}
}
else
{
currentCell.ErrorText = "Please enter a valid integer value";
}
break;
}
}
|