Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 710
  • Last Modified:

Trap function keys Winforms.

I have a windows form application with a few user specified options.  I could use radio buttons, but I would like to use function key to toggle options off and on.  For example F5 toggles between "SUMMARY DATA" and "DETAIL DATA", F6 toggles between "HOME" and "AWAY", etc.  I can't find any documentation on trapping when a function key is pressed.  This needs to work wherever control is on the form.
0
MGothelf
Asked:
MGothelf
1 Solution
 
AlexFMCommented:
Set Form KeyPreview property to true. Add KeyDown event handler:

void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
    if ( e.KeyCode == Keys.F5 )
    {
         ...
    }
    else if ( e.KeyCode == Keys.F6 )
    {
        ...
    }
    ...
}
0
 
MGothelfAuthor Commented:
THANK YOU!!!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now