Solved

Trap function keys Winforms.

Posted on 2006-11-06
2
705 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

730 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