Adding AdxRibbonMenu

Add-in Express™ Support Service
That's what is more important than anything else

Adding AdxRibbonMenu
 
Simon Murrell




Posts: 4
Joined: 2010-07-05
Hello

I am adding a AdxRibbonMenu to the AdxRibbonGroup when a user changes a value in a drop down. The code fires each time but no menu is added to the group. What am I doing incorrectly?


// Initialize Class
                toolbarItems = database.GetCollection(typeof(ToolbarsItemsModel));
                // Check Value
                if (toolbarItems != null)
                {

                    // Begin Update
                    this.adxRibbonGroup4.Controls.BeginUpdate();

                    try
                    {

                        // Clear Items
                        this.adxRibbonGroup4.Controls.Clear();
                        // Hide Menu Items Group
                        //this.adxRibbonGroup4.Visible = false;

                        // Search through Toolbars
                        foreach (ToolbarsItemsModel toolbarItem in toolbarItems)
                        {

                            // Check Value
                            if (toolbarItem.ToolbarsId.ToString().Equals(this.cboToolbars.SelectedItemId))
                            {

                                // Check Value
                                if ((toolbarItem.ParentToolbarsItemsId == null) &&
                                    (toolbarItem.Type.Equals("MenuItem")))
                                {

                                    // Initialize Class
                                    ADXRibbonMenu menu = new ADXRibbonMenu(this.components);
                                    // Add Control
                                    this.adxRibbonGroup4.Controls.Add(menu);
                                    // Assign Value
                                    menu.Caption = toolbarItem.Name;
                                    menu.Dynamic = true;
                                    menu.Id = "adxRibbonMenu_" + toolbarItem.ToolbarsItemsId.ToString();
                                    menu.ImageTransparentColor = System.Drawing.Color.Transparent;
                                    menu.Ribbons = ((AddinExpress.MSO.ADXRibbons)(((AddinExpress.MSO.ADXRibbons.msrExcelWorkbook | AddinExpress.MSO.ADXRibbons.msrWordDocument)
                                        | AddinExpress.MSO.ADXRibbons.msrPowerPointPresentation)));
                                    menu.ShowCaption = true;
                                    menu.Tag = toolbarItem.ToolbarsId;
                                    menu.Title = toolbarItem.Name;
                                    // Show Menu Items Group
                                    //this.adxRibbonGroup4.Visible = true;



                                }

                            }

                        }

                    }
                    finally
                    {

                        // End Update
                        this.adxRibbonGroup4.Controls.EndUpdate();

                    }

                }
Posted 20 Dec, 2016 10:34:14 Top
Andrei Smolin


Add-in Express team


Posts: 14104
Joined: 2006-05-11
Hello Simon,

I suggest that you start with the code which works: there are two code samples in section Creating Ribbon Controls at Run Time at https://www.add-in-express.com/docs/net-ribbon-components.php#ribbon-controls-runtime.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 21 Dec, 2016 05:37:44 Top