private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
     byte[] array = System.Text.Encoding.Default.GetBytes(e.KeyChar.ToString());
     if (!char.IsDigit(e.KeyChar)|| array.LongLength==2) e.Handled = true;
     //'\b'是退格键值
     if (e.KeyChar == '\b' || e.KeyChar == '.') e.Handled = false;
}

相关文章:

  • 2022-02-25
  • 2022-12-23
  • 2022-02-13
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-07-12
  • 2021-09-23
  • 2022-02-03
相关资源
相似解决方案