Showing posts with label Validation in grid cells. Show all posts
Showing posts with label Validation in grid cells. Show all posts

Tuesday, September 18, 2007

Validation in the grid cells

//Validating the Order column [Only numeric values allowed]
private void DataGrid1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
int newinteger;
if (e.ColumnIndex == 4)
{
bool Check = int.TryParse(e.FormattedValue.ToString(), out newinteger);
if (Check == false && e.FormattedValue.ToString() != "")
{
MessageBox.Show("Enter numeric value");
e.Cancel = true;
}
}
}