日期:2014-05-18 浏览次数:20932 次
private void TextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (!((e.KeyChar >= '0' && e.KeyChar <= '9') || (e.KeyChar >= 'A' && e.KeyChar <= 'F') || e.KeyChar == '\b'))
{
e.Handled = true;
}
}
------解决方案--------------------
把下面的代码放在窗体类中,来设置焦点
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
this.textBox1.Focus();
}