How To Enable Control Hosting On Quick Access Toolbar Items

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#

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).