You can handle the control’s KeyPress event and indicate the key has been handled. Below is code that prevents a TextBox from getting an ’A’ and the return key.
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar == (char)13 || e.KeyChar == ’A’)
e.Handled = true;
}
Share with