Handling KeyPress events in CF 2.0

Hi I have created a CF2.0 form with a picture box and running on a mobile device running WinCE 6.0 with USB keyboard connected.
I have to change the pictures in the "pictureBox" using keyboard keys. I have handled the "KeyPress" event for the form. But if I press any key on the keyboard, it is not generating any "event" in the form.

Any Ideas?
Thanks for your help.
//Defintion
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
 
//Event Handler
 private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            MessageBox.Show("KeyPress");
        }

Open in new window

ukalyanAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
Try setting the KeyPreview() Property of the Form to true:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview.aspx
0
All Courses

From novice to tech pro — start learning today.