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(
" 请输入数字! " );
}

}
}

 

 

 

你可能感兴趣的:(datagridview)