private void textBox1_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
e.Handled = System.Text.RegularExpressions.Regex.IsMatch(e.Text, @"[0-9]+");
base.OnPreviewTextInput(e);
}
转载于:https://www.cnblogs.com/liancs/archive/2011/08/01/3879298.html