If you are using ControlContainerItem to host controls, for example on popup menu which is parented to the button that can be added to the QAT (Quick Access Toolbar) on Ribbon Control you need to ensure that you are following steps below so control contained on the menu can be loaded when it is displayed on QAT.

When button or any other item is added to the QAT an item copy is created including any SubItems. ControlContainerItem is copied as well but not its assigned control since DotNetBar does not have knowledge necessary to create and setup custom control the same way that is done in original item.

To enable this usage case follow these steps:

1. Create an event handler for ContainerLoadControl that you will attach to two events. The event handler would look like this:
C#

private void Ribbon_ContainerLoadControl(object sender, EventArgs e)
{
    ControlContainerItem item = sender as ControlContainerItem;
 
    if (item != null && item.Name == controlContainerItem1.Name)
    {
        TrackBar tb = new TrackBar();
 
        tb.Maximum = 200;
        tb.Value = 50;
 
        item.Control = tb;
    }
}

VB

Private Sub Ribbon_ContainerLoadControl(sender As Object, e As EventArgs)
    Dim item As ControlContainerItem = TryCast(sender, ControlContainerItem)
 
    If item IsNot Nothing AndAlso item.Name = controlContainerItem1.Name Then
        Dim tb As New TrackBar()
 
        tb.Maximum = 200
        tb.Value = 50
 
        item.Control = tb
    End If
End Sub

Notice that item.Name property is used to select the proper item. Reason for that is to cover the QAT case where we are working with the copy of the ControlContainerItem. controlContainerItem1 refers to the item we created at design-time and which is on a menu for example. Also, notice that new instance of the control is created and assigned. You can reuse the instances if you know that only one instance will be visible at any point in time, which is the case when control is on menu.

2. Attach this event handler to RibbonBar.ContainerLoadControl and RibbonControl.RibbonStrip.ContainerLoadControl (this must be done from code, for example from form load event).

Related posts:

  1. How to add any control to menu, toolbar and other DotNetBar controls
  2. Ribbon Quick Access Toolbar Customization
  3. How to enable drag & drop on ItemPanel control
  4. Using QatCustomizePanel on custom Quick Access Toolbar customization dialogs
  5. Global Items