private string pattern = @"^[0-9]*$";
        private string param = "";


        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            Match m = Regex.Match(this.textBox1.Text, pattern);


            if (!m.Success) 
            {
                this.textBox1.Text = param;
                this.textBox1.SelectionStart = this.textBox1.Text.Length;
            }
            else
            {
                param = this.textBox1.Text;
            }
        }

 

posted on 2012-09-19 17:29    阅读(2003)  评论(0编辑  收藏  举报