?
Solved

C# Windows Form Menu Problem

Posted on 2006-03-29
13
Medium Priority
?
322 Views
Last Modified: 2010-05-18
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?
0
Comment
Question by:tsmolskow
  • 7
  • 6
13 Comments
 
LVL 14

Expert Comment

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

_______________

  Nayer Naguib
0
 

Author Comment

by:tsmolskow
ID: 16326183
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).
0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 16326235
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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:tsmolskow
ID: 16326419
Right, that is how I have it, and that is how it is suppose to work, but it's not working.
0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 16326735
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
0
 

Author Comment

by:tsmolskow
ID: 16326912
like this (?):

Text= menuFile.MenuItems[1].Mnemonic.ToString();
0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 16327095
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
0
 

Author Comment

by:tsmolskow
ID: 16327219
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.
0
 

Author Comment

by:tsmolskow
ID: 16327248
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?
0
 
LVL 14

Expert Comment

by:nayernaguib
ID: 16327289
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
0
 

Author Comment

by:tsmolskow
ID: 16327387
No, I double checked through the designer and code editor, I have only one MainMenu control
0
 
LVL 14

Accepted Solution

by:
nayernaguib earned 2000 total points
ID: 16327455
Maybe adding the third party toolbar component has some similar effect to adding other MainMenu controls!

_______________

  Nayer Naguib
0
 

Author Comment

by:tsmolskow
ID: 16327588
That's my thought - I will check with the vendor to see if there is a trouble ticket work around...
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Introduction to Processes

809 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