正则表达式的使用
using System.Text.RegularExpressions;
private string pattern = @"^[0-9]*$";
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
Match m = Regex.Match(this.textBox1.Text, pattern);
if (!m.Success)
{
this.textBox1.Text = resultVal;
// this.textBox1.SelectionStart = this.textBox1.Text.Length;
}
else
{
resultVal = this.textBox1.Text;
}
}