开发者

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;
        }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜