zoukankan      html  css  js  c++  java
  • C# 实现验证文本框中输入的是数值型??

     private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
      {

    //   if ( char.IsNumber(e.KeyChar) )
    //    {
    //    e.Handled = false;
    //    }
    //    else
    //    {
    //      e.Handled = true;
    //    }


       if(e.KeyChar>='a' && e.KeyChar<='z' || e.KeyChar>='A' && e.KeyChar<='Z' )
       {
        //字母
         e.Handled = true;
       }
       else if(e.KeyChar>='0' && e.KeyChar<='9')
       {
        //数字
        e.Handled = false;
       }
       else if(e.KeyChar=='_')
       {
        //下划线
         e.Handled = true;
       }
       else
       {
        //其他
         e.Handled = true;
       }


      }

  • 相关阅读:
    SpringMVC
    SpringMVC
    SpringMVC
    SpringMVC
    JavaWeb
    SpringMVC
    SpringMVC
    Spring
    Spring
    Spring
  • 原文地址:https://www.cnblogs.com/Fooo/p/462525.html
Copyright © 2011-2022 走看看