This is the function from Microsoft website to enter only numbers in the datagrid, it works fine.
I want to enable a button if a first cell value of the first row is a number??? How can I do this??
private void dataGridView1_CellValidating(object sender,
DataGridViewCellValidatingEventArgs e)
{
ThermalDatGrid.Rows[e.RowIndex].ErrorText = "";
int newInteger;
// Don't try to validate the 'new row' until finished
// editing since there
// is not any point in validating its initial value.
if (ThermalDatGrid.Rows[e.RowIndex].IsNewRow) {
return;
}
if (!int.TryParse(e.FormattedValue.ToString(),
out newInteger) || newInteger < 0)
{
e.Cancel = true;
ThermalDatGrid.Rows[e.RowIndex].ErrorText = "Only Numerical and Non Negative Values";
}
}
try: