限制数字0~9的输入

 1     private void txtKaisuu_KeyPress(object sender, KeyPressEventArgs e)
 2     {
 3         if ((e.KeyChar >= 32 && e.KeyChar <= 47) || (e.KeyChar >= 58 && e.KeyChar <= 126))
 4         {
 5             e.Handled = true;
 6         }
 7         else
 8         {
 9             e.Handled = false;
10         }
11     }

 

posted @ 2021-10-11 17:06  _jwj  阅读(109)  评论(0编辑  收藏  举报