private void txtPwd_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
{
this.btnLogin.Focus();
}
}
不能输入除数字之外的字符
private void IsNum(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 8)
{
return;
}
else if (e.KeyChar == 13)
{
SendKeys.Send("{Tab}");
}
else if (e.KeyChar > '9' || e.KeyChar < '0' && e.KeyChar != '.')
{
e.Handled = true;
MessageBox.Show("无效字符");
}
}