コード例 #1
0
 private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (TextBox.Text.Length >= Min | TextBox.Text.Length <= Max)
     {
         if (!string.IsNullOrEmpty(CaracteresValidos))
         {
             e.Handled = !CaracteresValidos.Contains(e.KeyChar.ToString());
             return;
         }
         if (InvalidateChar != null)
         {
             if (InvalidateChar.Contains(e.KeyChar.ToString()))
             {
                 e.Handled = true;
             }
         }
         e.Handled = false;
     }
     else
     {
         e.Handled = true;
     }
 }