KeyPreview = True and hotkeys

Posted on 2007-10-09
Medium Priority
Last Modified: 2007-10-09
I have a form that needs to trap for a keypress at the form level.  However, when I set KeyPreview to True it causes hotkeys and the Accept button to not work.

For instance, I have a button called Add with the A as a hotkey.  The button is also the AcceptButton for the Form.  When I press ALT-A or press Return, the button is not pressed.  How can I make this happen?
Question by:chlade
LVL 39

Accepted Solution

appari earned 2000 total points
ID: 20045656

can you show the existing code from your forms keypress/keydown/keyup events?
try after removing all the code from forms keypress/keydown/keyup events and check if behaviour is same. I tested here and it works fine ( no code in any of the form key_XXXXX events). so i think its some problem with your code in key events of your form.

Author Comment

ID: 20045689
That helped me find the problem ... though unfortunately not the solution.  But I know that I won't find the solution here.

The program is compiled as a DLL that is then loaded from our Accounting system.  This is where the problem is.  When I change the program to a standard Windows program and run it, it's fine.  There are a lot of flaky things going on when calling programs from our Accounting system so I'm sure that this is just one more.  Thanks!

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

829 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