这是我的代码:
private void txtAdd_KeyPress(object sender, KeyPressEventArgs e)
{
if (!(char.IsLetter(e.KeyChar)) && !(char.IsNumber(e.KeyChar)) && !(char.IsWhiteSpace(e.KeyChar)))
{
e.Handled = true;
}
}
它允许我输入字母、数字和空格,但不允许我使用退格键。请帮帮我。
'\b'
代替(char)8
。 - Alex Humphrey(char)Keys.Back
。 - Antonio