textbox只能输入数字

View Code
1 private void txtJustNumber_KeyPress(object sender, KeyPressEventArgs e)
2 {
3 if (e.KeyChar != 8 && !char.IsDigit(e.KeyChar) && e.KeyChar != 13)
4 {
5 MessageBox.Show("只能输入数字");
6 e.Handled = true;
7 }
8 }

posted on 2011-04-14 16:55  源远流长  阅读(160)  评论(0编辑  收藏  举报

导航