Link to home
Start Free TrialLog in
Avatar of tsmolskow
tsmolskow

asked on

C# Windows Form Menu Problem

I'm using C# Windows Form Menu control, and I have added short cuts using the "&" symbol, and the short cuts show at design time (as underlined letters) but they don't show at run time.  What am I doing wrong?
Avatar of nayernaguib
nayernaguib
Flag of Egypt image

Nothing wrong! Shortcut keys get underlined when you press the Alt key. Afterall, this is how you can use the shortcut keys. :-)

_______________

  Nayer Naguib
Avatar of tsmolskow
tsmolskow

ASKER

Hey Nayer, I just tried that but no luck, they don't show up and the don't function (for example, pressing Alt+F does not open the file menu).
If the Text property is "&File" (as an example), then when you press the Alt key, the F letter will get underlined. Next, when you press F (while holding down the Alt key), the menu gets opened.

_______________

  Nayer Naguib
Right, that is how I have it, and that is how it is suppose to work, but it's not working.
As far as I know, you can do *nothing* to disable this feature! Even when the menu item is disabled, the Alt+Key combination selects the menu item!

Try to do this: place the following line of code in the Form Load event handler. It should put the shortcut character of the specified menu item in the titlebar of the form.

      Text=myMenu.MenuItems[someIndex].Mnemonic.ToString();

Replace myMenu with the name of your menu, and someIndex with any valid item index.

Another thing to check: Try to press Alt+F (or any other combination) while using any Windows application (such as Internet Explorer), and Make sure that some letter is underlined.

_______________

  Nayer Naguib
like this (?):

Text= menuFile.MenuItems[1].Mnemonic.ToString();
Are you using multiple MenuItem controls on the same form?
You should use only one control, and use it add *all* required menus and submenus.

You cannot have menuFile, menuEdit, menuView, etc...
You should have one control (for example, mainMenu). You can use mainMenu.MenuItems[index1] to access main menu items (such as File, Edit, etc...), and mainMenu.MenuItems[index1].MenuItems[index2] to access submenus (such as New, Open, Save submenus of the File menu).

If that is your problem, create a new empty project, and try using only one MainMenu control. Trying to modify your current project by removing additional MainMenu controls will possibly not work.

_______________

  Nayer Naguib
Hey Nayer, Well I'm just using the MS MainMenu control, not any of the others, but I'm also using some third party components, but they don't have a menu component, just a tool bar component.  I'll try a whole new project without the components, and LYK.  Thanks for hanging in there, I really need to solve this mystery.  BTW, this project has to be in 1.1, I know 2.0 is an improvement, but I can't use that right now.
Well, the test project performs as you described, so it's possibly related to the components - at least that's my best guess, your thoughts?
I was not talking about using other types of controls, but rather about having multiple MainMenu controls on one form. This does not work.
If that is what you were doing, then most probably this is your problem.

_______________

  Nayer Naguib
No, I double checked through the designer and code editor, I have only one MainMenu control
ASKER CERTIFIED SOLUTION
Avatar of nayernaguib
nayernaguib
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's my thought - I will check with the vendor to see if there is a trouble ticket work around...