Accelerators not being displayed

  • Thread starter Thread starter Ken Allen
  • Start date Start date
K

Ken Allen

When I create and position a new button programmtically, the accelerator is
not being displayed when the form is displayed.
In the code below, the button is displayed simply as "Exit", not with the
"x" character underlined.
If I press alt-X, the button handler is processed.
Actually, some further testing reveals that the accelerator characters are
not always displayed when the form is first displayed, even if they are
placed there in the designer, at least under the conditions where there is
at least one button being added programmatically. When the ALT key is
pressed the first time, then the accelerators appear.

Is this a 'bug' or a 'feature'?

-ken

_Actions[buttonIndex] = new Button();

_Actions[buttonIndex].Size = new System.Drawing.Size(buttonWidth,
buttonHeight);

_Actions[buttonIndex].Location = new Point(xPosition, yPosition);

_Actions[buttonIndex].Name = "btnExit";

_Actions[buttonIndex].TabIndex = tabIndex++;

_Actions[buttonIndex].Text = "E&xit";

_Actions[buttonIndex].Click += new EventHandler(Exit_Click);

this.Controls.Add(_Actions[buttonIndex]);
 
Ken - This is a feature of Windows and not .Net. It is a global option
setting for windows and effects all programs. Don't know if there is a way
to turn it on just for your app.

In XP, the setting is under control panel - display - appearance - effects
"Hide the underline letter for keyboard....."

HTH,
Brian
 
Back
Top