Hi,
I have this code in my form constructor:
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.onKeyPress);
and below after the constructor I have this one:
private void onKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
textBox1.Text = "uuuuu";
}
and it does not work...
Why, it seems all ok in the code?
Regards,
Mirza
Key Event does not work on simple form...
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Jan MontanoRank #1,295 · 1.3K reputationPosted Aug 29, 2007, 9:46 PM EDT
Try creating a plain form with the keypress eventhandler (with no other controls in it ) except that you'll display a messagebox instead inside the onkeypress method. it should work. But try placing a textbox insdie the form and it will not work. The reason is, the focus will be on the textbox when you run the application.