WinForm下 TextBox只允许输入数字的小例子_C#教程

分享到:

 private void txtBarCode_KeyPress(object sender, KeyPressEventArgs e)
        {
            int ikc = (int)e.KeyChar;
            if ((!System.Text.RegularExpressions.Regex.IsMatch(e.KeyChar.ToString(), "[0-9]")) && ((int)e.KeyChar) != 8)
            {
                e.Handled = true;
                return;
            }
        }
昵    称:
验证码:

相关文档: