How to add a menu dynamically with Command

Topics: CAB & Smart Client Software Factory
Aug 4, 2006 at 2:34 PM
originally posted by: ramyrams

I have added the menu like

PopupMenuTool Services = new PopupMenuTool("Services");
Services.SharedProps.Caption = "Services";

this.UIExtensionSites“Services”.Add(Services);
this.UIExtensionSites.RegisterSite(“ServicesDropDown”, Services.Tools);

foreach (ToolBase bt in serviceMenu.Tools)
{
ButtonTool ServiceChild = new ButtonTool(bt.SharedProps.Caption);
ServiceChild.SharedProps.Caption = bt.SharedProps.Caption;
this.UIExtensionSites“ServicesDropDown”.Add(ServiceChild);
this.Commandsbt.Key.ToString().AddInvoker(ServiceChild, "ToolClick");
ServiceChild = null;
}

Note: PopupMenuTool is Infragistic tools.

Currently assume that I have 3 item in Popupment then I will 3 commands as

CommandHandler("CS_Tasks1")
public void OnCSTasks1ViewSelected(object sender, EventArgs e)
{
LoadWorkItem("CS Tasks1");
}

CommandHandler("CS_Tasks2")
public void OnCSTasks2ViewSelected(object sender, EventArgs e)
{
LoadWorkItem("CS Tasks2");
}

CommandHandler("CS_Tasks3")
public void OnCSTasks3ViewSelected(object sender, EventArgs e)
{
LoadWorkItem("CS Tasks3");
}


Is there any way to dynamically added the commands to each item?


Basically I need to add a menu item dynamically.
Aug 4, 2006 at 8:29 PM
originally posted by: askew

Chris Holmes has a blog entry that might interest you. He uses a Service internal to his Application to provide toolstrip menu items dynamically. I think his buttons know how to run the Commands that match their names in his example.

http://www.chrisholmesonline.com/2006/07/24/managing-toolstrip-state-in-a-cab-application-chain-of-responsibility/#comments

You are setting "ServiceChild = null;" in your code...? I'm not familiar with the Infragistics tools.
Aug 5, 2006 at 7:30 AM
originally posted by: ramyrams

Thanks for the URL let me thy this.