protected override void OnKeyDown(KeyEventArgs e)
if (e.KeyCode == Keys.Enter)
e.SuppressKeyPress = true; // stop the bell!!!
Sunday, 6 June 2010
If you're a fan of your keyboard shortcuts, you might notice that windows sometimes emits a beep (or bell) after pressing enter to select something. Prevent the bell by setting the KeyDown eventargs SuppressKeyPress member to 'true' if the enter key was pressed.
Sick of the c# designer setting your control's property to null in the InitializeComponent() function? Then simply set the property's default value to null so InitializeComponent() doesn't have to!