C# datagridview只允许输入数字

private void dgvData_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
  if (this.dgvData.CurrentCell.ColumnIndex == 3)
    {
      e.Control.KeyPress += new KeyPressEventHandler(TextBoxDec_KeyPress) ;
    }
}
private void TextBoxDec_KeyPress(object sender, KeyPressEventArgs e)
{
  if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')
   {
     e.Handled = true;
   }
}

 

上一篇:【SAP】SNOTE手工打notes


下一篇:webpack2 前篇