TextBox只允许输入数字

public class NumericTextBox  : TextBox 

 

 

protected override void OnKeyPress(KeyPressEventArgs e)
  {
   if (!char.IsDigit(e.KeyChar))
   {
    e.Handled = true;
   }

   if (!Char.IsDigit(e.KeyChar))
   {
    e.Handled = true;
   }
  }

posted on 2008-10-12 00:58  原始部落  阅读(217)  评论(0)    收藏  举报