Input only Decimal No in TextBOx
I have a DataGridView and I want to validate only Decimal No Should be input in a Cell i am u开发者_开发知识库sing window Form and i am generating Column in DataGridView Dynamically
Plz help me
Use the CellValidating
event:
private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.ColumnIndex == theColumnToValidate.Index)
{
decimal d;
if (!decimal.TryParse(e.FormattedValue.ToString(), out d))
{
MessageBox.Show("Please enter a decimal number");
e.Cancel = true;
}
}
}
精彩评论