您的位置:首页 > 其它

控制TextBox控件只输入数字的解决办法

2008-06-18 13:59 302 查看
1private void focusValue_KeyPress(object sender, KeyPressEventArgs e) 2 { 3 TextBox textbox = (TextBox)sender; 4 int t = e.KeyChar; 5 if (t == 0x8) // 退格键 6 return; 7 if (t == 0xd) // 回车键 8 return; 9 10 if (t < 0x30 || t > 0x39) 11 e.Handled = true; 12 } 13
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: