Add Submenu

Topics: CAB & Smart Client Software Factory
Jul 31, 2007 at 10:54 AM

Hi.

I´m trying to add a submenu dynamically to my File-Menu.

To do this, i registered the file menu in "ShellLayoutViewPresenter" like this:
WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenu, View.FileMenu)

Added the following code to UIExtensionSiteNames:
public const string FileMenu = "FileMenu";

Then added the following code to the ShellLayoutViewPresenter:
internal ToolStripMenuItem FileMenu
{
get { return _fileToolStripMenuItem; }
}

finally, I tried to extend the menu in my modules Modulecontroller using the ExtendMenu function like this:

ToolStripMenuItem objMenuItem = new ToolStripMenuItem();
objMenuItem.Name = "_showTaskList";
objMenuItem.Tag = "ShowTaskList";
objMenuItem.Text = Properties.Resources.ModuleTitle;
WorkItem.UIExtensionSites[Constants.UIExtensionSiteNames.FileMenu].Add(objMenuItem);
WorkItem.Commands["ShowTaskList"].AddInvoker(objMenuItem, "Click");

When i start the application, the menu item is being displayed, but not as a subitem of my file menu. It´s being displayed after my file menu.

What am I doing wrong?

Thanx for your help in advance.

Florian
Jul 31, 2007 at 11:48 AM

WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenu, View.FileMenu)


Try changing the above to
 WorkItem.UIExtensionSites.RegisterSite(UIExtensionSiteNames.FileMenu,View.FileMenu.DropDownItems)

__Allan
Jul 31, 2007 at 12:11 PM
Worked perfectly.

Thank you very much!