Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
575
How to create a context menu automatically
posted

Hello,

 I used ContextMenuStrip and ToolStripMenuItem, but now I want to use the same thing in infragistics. I know it is by using ultraToolbarsManager, but I do not know how to do that.

This is how I want it to happen:

Create the context menu automatically, programmatically, and assign it to UltraDropDownButton. So when the UltraDropDownButton is clicked, this context menu is shown.

Is there any altenative way to show the DropDownButton menu?

 

  • 44743
    posted

    Using a context menu is not the best way to show a menu in an UltraDropDownButton. Instead, define the popup menu on your toolbars manager. Then set the PopupItem on the UltraDropDownButton to the root menu:

    PopupMenuTool menu = new PopupMenuTool( "Menu" );

    ButtonTool button1 = new ButtonTool( "Button1" );
    button1.SharedProps.Caption = "Button 1";

    ButtonTool button2 = new ButtonTool( "Button2" );
    button2.SharedProps.Caption = "Button 2";

    this.ultraToolbarsManager1.Tools.AddRange( new ToolBase[ { menu, button1, button2 } );

    menu.Tools.AddToolRange( new string[ { button1.Key, button2.Key } );

    this.ultraDropDownButton1.PopupItem = menu;