Menu Item (Commands) Ordering

Topics: CAB & Smart Client Software Factory
Dec 2, 2005 at 3:43 AM
originally posted by: allann

Is there a way to specify the order in which menu items appear both in the Root Menu and in Drop Down Menus? I have a Shell Application that contains File and Help, but when I load an optional module that contains commands, they are always inserted at the end of the menu strip.

Maybe you can also tell me how I can change the text during runtime, of an existing menu item from another module (i.e. I dont have a reference to the ToolStripMenuItem, just the UiExtension).
Dec 2, 2005 at 7:05 PM
originally posted by: BlairLeduc

I can tell you how I solved the first question: what I found (in the samples) that if you place a UIExtensionSite at a tool strip menu item, any menu items you add will be placed after that point. So I set my menus up like so:

File Help
FileInsertPoint About...
Exit

I used the following code in my AfterShellCreated:

ToolStripMenuItem fileItem = (ToolStripMenuItem)Shell.MainMenuStrip.Items"File";
RootWorkItem.UIExtensionSites.RegisterSite("fileMenu", fileItem.DropDownItems"FileInsertPoint");
RootWorkItem.UIExtensionSites.RegisterSite("mainMenu", fileItem);

When you add to the "fileMenu" extension site, the items will be added after a hidden "fileInsertPoint" menu item and before the exit menu item. When you add to the mainMenu, the item will be added after "File" and before "Help".

I don't know how to change the name of the menu item.

Blair.
Dec 4, 2005 at 3:31 PM
originally posted by: allann

Thank Blair, that at least gets around the first issue, I just thought it strange that since this was to help "module" builders, they can't eaily insert into a menu at a given spot, instead registered sites need to be created for ALL places you might need to insert menus. Quite a limitation. Same goes for toolbar buttons.

It wasn't the name I wanted to change, it was the menu text. Because the application is module driven (I change a few menu text value to suit the loaded modules (they still need to be present and function even if optional modules aren't loaded, so this stops me from putting them into the modules only). I was goning to duplicate the menus to get around the problem, so module has one with one name and shell has the original. And then hide the shell one if the modules are loaded. But this caused many other issue i won't go into here.

Thanks for your response.

Allan