数字的验证
数字和字母的混合验证
- private void textBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
- {
- if(e.KeyChar < '0' || e.KeyChar > '9')
- e.Handled = true;
- }
- private void textBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
- {
- if((e.KeyChar>='0'&&e.KeyChar<='9')||(e.KeyChar>='A'&&e.KeyChar<='Z')||e.KeyChar>='a'&& e.KeyChar<='z'))
- e.Handled=false;
- else
- e.Handled=true;
- }