You can prevent the beep when the enter key is pressed in a TextBox by deriving the TextBox and overriding OnKeyPress.
[C#]
public class MyTextBox : TextBox
{
protected override void OnKeyPress(KeyPressEventArgs e)
{
if(e.KeyChar == (char) 13)
e.Handled = true;
else
base.OnKeyPress (e);
}
}
[VB.NET]
Public Class MyTextBox
Inherits TextBox
Protected Overrides Sub OnKeyPress(e As KeyPressEventArgs)
If e.KeyChar = CChar(13) Then
e.Handled = True
Else
MyBase.OnKeyPress(e)
End If
End Sub ’OnKeyPress
End Class ’MyTextBox
Share with