winform 只能输入数字(小数)

来源:互联网 发布:软件疲劳强度测试 编辑:程序博客网 时间:2024/04/19 22:55

     看到了,记一下

\b退格

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)        {            if (e.KeyChar != '\b' && !Char.IsDigit(e.KeyChar) && e.KeyChar != '.')            {                e.Handled = true;            }          }



0 0