if(!System.Text.RegularExpressions.Regex.IsMatch(textBox1.Text,@"^\d*$"))textBox1.Undo();参考:
http://expert.csdn.net/Expert/TopicView3.asp?id=1122481

解决方案 »

  1.   

    用这个控件吧:numericUpDown难道非用文本框?
      

  2.   

    这是我曾经写过的一段代码,保证没有问题,绝对符合你的要求
    private void textBoxNumber_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
    {
    if((int)e.KeyChar>=48&(int)e.KeyChar<=57|(int)e.KeyChar==8)//这段代码用于检验用户输入的是不是数字,同时兼顾了像DEL、Backspace、Tab、数字小键盘等这些键的功能的正常运行。
    {
    e.Handled=false;
    }
    else
    {
    e.Handled=true;
    }
    }