zoukankan      html  css  js  c++  java
  • 限制输入类型

     if (!Char.IsLetterOrDigit(e.KeyChar) && !Char.IsPunctuation(e.KeyChar) && !Char.IsControl(e.KeyChar) && e.KeyChar != (char)Keys.Back)   //IsNumber仅数字
                {
                    e.Handled = true; //获取或设置一个值,指示是否处理过System.Windows.Forms.Control.KeyPress事件
                }
                else if (Char.IsPunctuation(e.KeyChar))
                {
                    if (e.KeyChar == '.')
                    {
                        if (((TextBox)sender).Text.LastIndexOf('.') != -1)
                        {
                            e.Handled = true;
                        }
                    }
                    else
                    {
                        e.Handled = true;
                    }
                }
               
               
    限制输入类型 IsNumber是仅数字   IsLetterOrDigit是英文字母和数字  IsPunctuation是标点符号  Back是键盘回格键
    些列小数点可用

    -----------------------------------------------------------

     private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
            {
                if (e.KeyChar >= (char)Keys.D0 && e.KeyChar <= (char)Keys.D9 || e.KeyChar == (char)Keys.Back)
                {
                    e.Handled = false;
                }
                else
                {
                    e.Handled = true;
                }
            }
     限制文本框输入类型只能输入数字

  • 相关阅读:
    OpenCV 图像二值化 threshold
    C++ pow()函数
    Marr-Hildreth 边缘检测 OpenCV C++实现
    OpenCV 边缘检测 Canny
    OpenCV Canny()函数
    OpenCV Sobel()函数
    OpenCV 边缘检测 Sobel
    OpenCV 边缘检测 Laplacian
    OpenCV 边缘检测 Scharr
    OpenCV 形态学变换 morphologyEx函数
  • 原文地址:https://www.cnblogs.com/zzh1236/p/1389190.html
Copyright © 2011-2022 走看看