When creating new RibbonBar controls and adding them to the Ribbon panels use following tips:

  1. When RibbonBar controls are created and added to the RibbonPanel from code, the layout order of controls is determined by the actual layout position of the RibbonBar control, that is to say RibbonBar.Left property. To ensure proper order for your controls make sure that you set RibbonBar.Left property so it can be used to layout controls. If you are adding multiple RibbonBar controls and setting the Left property make sure to start that operation with RibbonPanel.SuspendLayout and RibbonPanel.ResumeLayout when your addition is complete.
  2. If creating and adding RibbonTabItem objects or adding other items to the RibbonControl.Items collection from code after you are done adding all new items make sure you call RibbonControl.RecalcLayout to apply the layout changes.
  3. Call RibbonBar.RecalcLayout method once after you are done adding all items to the RibbonBar. This will resize the bar and perform layout on all items inside of bar. You need to call RecalcLayout every time you make change that affects the layout or appearance of the items. This applies to any DotNetBar control with RecalcLayout method.
  4. Use RibbonControl.CreateRibbonTab factory method to create new Ribbon Tab and associated panel.
  5. After all RibbonBar controls are added to the ribbon panel call once RibbonPanel.PerformLayout to perform layout of all RibbonBar controls on a panel. Note that control and form should be visible so layout can be performed.
  6. Make sure that you explicitly select the ribbon tab after you have created all tabs.You can use RibbonControl.SelectFirstVisibleRibbonTab() method to select first visible tab.
  7. By default RibbonPanel which hosts your RibbonBar controls performs automatic RibbonBar layout which is designed so it can display as much of RibbonBar content as possible. When there is not enough space available, it will start automatically shrinking RibbonBar controls by changing their layout or if that does not achieve the goal of showing all RibbonBar control, RibbonPanel will collapse the RibbonBar into single button. This functionality is designed to follow how Office 2007/2010 Ribbon behaves. You can turn off the automatic RibbonBar layout by setting RibbonPanel.DefaultLayout=true which will give you full control of layout inside of RibbonPanel, i.e. layout will be same as for any other Panel control.

Sample that you can download below shows how to ensure that RibbonBar layout is performed if change is made to its size and other controls on panel are affected.

Related posts:

  1. How to loop through all ribbon tabs, ribbon bar and items on WinForms Ribbon control
  2. Working with DotNetBar from code.
  3. How To Perform Custom Ribbon Merging
  4. Ribbon Control re-sizing modes and support for different DPI settings
  5. Ribbon Quick Access Toolbar Customization