IsDecimal() public static method

public static IsDecimal ( string str ) : bool
str string
return bool
Ejemplo n.º 1
0
 public static void TextBoxDecimalFilter(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar.ToString() == "\b" || e.KeyChar.ToString() == "." || e.KeyChar.ToString() == "-")
     {
         string str;
         if (e.KeyChar.ToString() == "\b")
         {
             e.Handled = false;
             return;
         }
         else
         {
             str = ((TextBox)sender).Text.Trim() + e.KeyChar.ToString();
         }
         if (Utility.IsDecimal(str) || str == "-")
         {
             e.Handled = false;
             return;
         }
     }
     if (!char.IsDigit(e.KeyChar))
     {
         e.Handled = true;
     }
 }
Ejemplo n.º 2
0
        public static void DataGridViewIntFilter(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar.ToString() == "\b" || e.KeyChar.ToString() == "-")
            {
                string str;
                if (e.KeyChar.ToString() == "\b")
                {
                    e.Handled = false;
                    return;
                }
                else
                {
                    str = ((DataGridViewTextBoxEditingControl)sender).Text + e.KeyChar.ToString();
                }

                if (Utility.IsDecimal(str) || str == "-")
                {
                    e.Handled = false;
                    return;
                }
            }
            if (!char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }