Dynamically add menu items to the shell form

Topics: CAB & Smart Client Software Factory
Nov 27, 2007 at 2:46 PM
Hi all,

Is there an example somewhere out there how to create a dropdown menu item dynamically and associate the menu item to an existing click event?

Nov 28, 2007 at 3:02 PM

To add dynamically a menu to the a menu strip you should add the following code in the ExtendMenu method of the ModuleController.

private void ExtendMenu()
    // Create a menu.
    ToolStripMenuItem menu = new ToolStripMenuItem("My menu");
    ToolStripMenuItem menuItem = new ToolStripMenuItem("My item");
    // Add an item to the drop down list of items.
You can use Commands to associate a menu item to an existing click event. What you should do is put the CommandHandler attribute in the top of the method and add the menu item as invoker of this command.
I recommend you to read the followings topics in the SCSF documentation:
  • Smart Client Software Factory -> Inspecting the Software Factory Assets -> Application Blocks -> Composite UI Application Block -> Developing Applications Using the Composite UI Application Block -> Registering Commands

Please let me know if this helps.

Mariano Converti
Nov 28, 2007 at 3:45 PM
Hi Mariano,

Thank you very much the information. My question was not right but anyway, I used the UIElementBuilder to resolve my problem and made a post at
how I resolved the problem.
Thanks again.