Apr 24
Typically when you press the Enter key while typing in a TextBox control, you will hear the computer beep.
To prevent this beep, handle the Enter key in the KeyPress event, and set the Handled property to true. For example:
void TextBox_KeyPress( object sender, KeyPressEventArgs e ) { switch (e.KeyChar) { case 'r': // perform necessary action e.Handled = true; break; } }









You can also do that:
private void textBox_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
}
}
Great answer!!
e.SuppressKeyPress = true;
works perfectly.
Amaziiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiinngggggg
:):)