Solved

Trap function keys Winforms.

Posted on 2006-11-06
2
699 Views
Last Modified: 2008-02-01
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
Comment
Question by:MGothelf
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 125 total points
ID: 17883256
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
 

Author Comment

by:MGothelf
ID: 17883444
THANK YOU!!!!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
New to SOAP and need some direction 10 40
Please explain "Multi-Tenant Services" 5 60
Class object 2 26
How would you add MULTITHREADING to the attached C# code? 4 51
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now