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.
MGothelfAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
AlexFMConnect With a Mentor Commented:
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
All Courses

From novice to tech pro — start learning today.