Accelerator keys broken in Winforms

G

Guest

I'm having a problem with accelerator keys (also sometimes refered to as
shortcut keys or mnemonics) on Winforms. To reproduce, simply do this:
1. create a new C# "Windows Application" project (I'm using VS2005)
2. Add a button to the form and change its default Text from "button1" to
"&button1"

Now run the app. Press the alt key on the keyboard and the keyboard cue is
displayed (the 'b' becomes underlined) as it should. Press the alt key again
and the
underline does not go away. You will also notice that pressing the 'b' key
fires the button's click event regardless of whether the alt key was ever
pressed, or whether the cue is visible.

Surely this isn't "by design" (Menus don't work this way! OS supplied
dialogs don't work this way!)

Any pertinent suggestions on how to work around this would be welcome. TIA
 
H

Herfried K. Wagner [MVP]

km said:
I'm having a problem with accelerator keys (also sometimes refered to as
shortcut keys or mnemonics) on Winforms. To reproduce, simply do this:
1. create a new C# "Windows Application" project (I'm using VS2005)
2. Add a button to the form and change its default Text from "button1" to
"&button1"

Now run the app. Press the alt key on the keyboard and the keyboard cue is
displayed (the 'b' becomes underlined) as it should. Press the alt key
again
and the
underline does not go away. You will also notice that pressing the 'b' key
fires the button's click event regardless of whether the alt key was ever
pressed, or whether the cue is visible.

Surely this isn't "by design" (Menus don't work this way! OS supplied
dialogs don't work this way!)

This behavior is by design and can be found in all Windows application which
use Windows' controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top