Beispiel #1
0
 private void Number_PreviewTextInput(object sender, TextCompositionEventArgs e)
 { //only  digits
     try
     {
         TextBox textBox = sender as TextBox;
         HelpClass.InputJustNumber(ref textBox);
         Regex regex = new Regex("[^0-9]+");
         e.Handled = regex.IsMatch(e.Text);
     }
     catch (Exception ex)
     {
         HelpClass.ExceptionMessage(ex, this);
     }
 }
 private void Number_PreviewTextInput(object sender, TextCompositionEventArgs e)
 {
     try
     {
         //only  digits
         TextBox textBox = sender as TextBox;
         HelpClass.InputJustNumber(ref textBox);
         if (textBox.Tag.ToString() == "int")
         {
             Regex regex = new Regex("[^0-9]");
             e.Handled = regex.IsMatch(e.Text);
         }
         else if (textBox.Tag.ToString() == "decimal")
         {
             input     = e.Text;
             e.Handled = !decimal.TryParse(textBox.Text + input, out _decimal);
         }
     }
     catch (Exception ex)
     {
         HelpClass.ExceptionMessage(ex, this);
     }
 }