zoukankan      html  css  js  c++  java
  • C#的TextBox控件输入测试只允许输入数字的测试:

     

     

    代码如下: (VS2005)

           public TextBoxInputCheck(object sender, KeyPressEventArgs e,INPUTTYPE type)
           {
                if(type == INPUTTYPE.INT)
                {
                    string pattern = @"^[0-9]";
                    Regex reg = new Regex(pattern);
                    if ((!reg.Match(e.KeyChar.ToString()).Success) && (e.KeyChar.ToString() != ""))
                    {
                        e.Handled = true;
                    }
                }
                else if(type == INPUTTYPE.FLT)
                {
                    string pattern = @"^[0-9]|.$";
                    Regex reg = new Regex(pattern);
                    if ((!reg.Match(e.KeyChar.ToString()).Success) && (e.KeyChar.ToString() != ""))
                    {
                        e.Handled = true;
                    }
                    else if (e.KeyChar.ToString() == "." && (sender as TextBox).Text.IndexOf('.') > 0)
                    {
                        e.Handled = true;
                    }
                }    
            }

  • 相关阅读:
    k8s二进制安装
    jenkins
    Deploy Apollo on Kubernetes
    Apollo配置中心搭建常见报错
    Apollo配置中心搭建过程
    使用CephRBD为Kubernetes提供StorageClass
    Ceph基础命令总结
    Ceph分布式存储系统搭建
    zabbix入门之配置邮件告警
    zabbix入门之定义触发器
  • 原文地址:https://www.cnblogs.com/twttafku/p/1131200.html
Copyright © 2011-2022 走看看