Capturing Keypress - No Keycode property available ??

S

sULs

Hi all

Hoping someone can help !!

I am trying to catch F2 - 6 key presses in a winforms application

Code as follows

private void frmMain_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
/*MessageBox.Show(e.KeyChar.ToString());*/

if(e.KeyCode == Keys.F2 )
MessageBox.Show("F2");
}

Now e is capturing the keypress fine (the messagebox works fine for
alpha\numeric) , however property wise for e i only have

KeyChar
Handled
and the usual tostring() etc

Thus can not test for keys.F2 as i have no e.Keycode ..(the
if(e>keyCode does not work )

Any ideas anyone ? Sure Im missing something simple but cant see it.

TIA Dave
 
S

sULs

Appears I DO have the required properties on Keydown and Keyup events
which guess is good enough !!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top