datagridview cell 验证事件

 

 

private void baseDataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (e.ColumnIndex == 5 && this.baseDataGridView1.CurrentCell.IsInEditMode)
{
string sVal = this.baseDataGridView1.CurrentCell.EditedFormattedValue.ToString();
try
{
decimal.Parse(sVal);
}
catch (Exception)
{
e.Cancel
= true;
MessageBox.Show(
"请输入数字!");
}

}
}

 

 

 

posted @ 2010-06-26 11:33  庚武  Views(287)  Comments(0Edit  收藏  举报