I need to set f2 key to button on my winform
private void UserPopUp_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == (char)Keys.Enter)
{
button3.PerformClick();
}
if (e.KeyChar == (char)Keys.F1)
{
MessageBox.Show("hi");
uaddbtn.PerformClick();
}
if (e.KeyChar == (char)Keys.F3)
{
button1.PerformClick();
}
if (e.KeyChar == (char)Keys.Escape)
{
MessageBox.Show("hi");
}
}
but here f1 and f3 buttons are not working.Enter and escape is working
please help to set these f1 and f3 keys to perform above actions
Set function keys to button click
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Posted Oct 10, 2013, 9:22 PM EDT
The key press event not support the keys from f1 to f12, but keydown supports use keydown event to solve your problem
IN WPF
Use Preview Key down event