I wonder why this code never runs when I release a key.
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
MessageBox.Show("It works!");
}
In designer this code is added as usual:
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyUp);
However events like Form load works perfect. Is there any common solutions for this problem?
You should set the KeyPreview
property of the form to true, this should work with your code.
If the form has other controls on it try setting the Form.KeyPreview property to true: Key Preview on MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With