how to validate cell of datagridview enter only number in this cell
thanks,
Shailaja
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vidya YadavPosted Sep 26, 2009, 3:17 AM
Use this code piece to solvw your problem.. Hope it will work
private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
dataGridView1.Rows[e.RowIndex].ErrorText = "";
double newInteger;
if (dataGridView1.Rows[e.RowIndex].IsNewRow)
{
return;
}
Vidya
if (!double.TryParse(e.FormattedValue.ToString(), out newInteger) || newInteger < 0)
e.Cancel = true;
dataGridView1.Rows[e.RowIndex].ErrorText = "the value must be a non-negative integer";
}
Shailaja MohitePosted Sep 26, 2009, 3:41 AM
How To Create Custome Columns In DatagridView in C# dotnet
thanks
Shailaja
Shailaja MohitePosted Sep 26, 2009, 3:37 AM
Roei BarPosted Sep 26, 2009, 3:34 AM