private void textBox1_KeyPress(object sender, KeyPressEventArgs e)//只能输入数字和ABCDEFG,小字字母自动转换为大写字母{if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || (e.KeyChar >= 65 && e.KeyChar <= 70) || (e.KeyChar >= 97 && e.KeyChar <= 102))&& e.KeyChar != 8&& e.KeyChar != 127)e.Handled = true;//48-57为数字0-9,65-70为大写字母A-F,97-102为小写字母a-f,8为退格键,127为删除键(43为+,45为- 46为.额外注释 )e.KeyChar = Convert.ToChar(e.KeyChar.ToString().ToUpper());//将小写字母转换为大写字母}
700字范文,内容丰富有趣,生活中的好帮手!