You can drop-down any .NET control from either menu or toolbar with the help of the ButtonItem class. We recommend to create UserControl that describes your custom popup.

Follow these steps to create your custom popup:

  1. Add new UserControl to your project and design it the way you want your popup to look like
  2. Open DotNetBar Windows Forms designer and create new ButtonItem that will be used to drop-down your custom popup control
  3. Set the PopupType property of that ButtonItem to ePopupType.Container
  4. Add event handler for PopupContainerLoad event on DotNetBarManager if you are using DotNetBarManager or for the appropriate control
  5. Add the code to that event that will recognize the ButtonItem you created in step 2 by checking the name property
  6. Using the ButtonItem.PopupContainerControl.Controls.Add method add the new instance of the UserControl you created in step 1 to the ButtonItem
  7. Make sure that you set the position and size of your UserControl accordingly
  8. Consider handling PopupContainerUnload event if you want to preserve your control so you can use it on drop-down again. You will have to remove it from PopupContainerControl and store it somewhere. When popup container is disposed all child controls will be disposed as well. If you create new instance of the control each time and add it to the popup like the example below, then handling PopupContainerUnload event is not necessary.

Following code from the Notepad sample demonstrate how to assign your custom UserControl to the ButtonItem:

C#

private void LoadPopup(object sender, System.EventArgs e)
{
    ButtonItem item=sender as ButtonItem;
 
    if (item.Name == "bTextColor")
    {
        DevComponents.DotNetBar.PopupContainerControl container = item.PopupContainerControl as PopupContainerControl;
        ColorPicker clr = new ColorPicker();
 
        container.Controls.Add(clr);
        clr.Location=container.ClientRectangle.Location;
        container.ClientSize=clr.Size;
    }
}

VB

Private Sub LoadPopup(ByVal sender As Object, ByVal e As System.EventArgs)
    Dim item As ButtonItem=CType(sender,ButtonItem)
 
    If item.Name="bTextColor" Then
        Dim container As DevComponents.DotNetBar.PopupContainerControl=CType(item.PopupContainerControl,PopupContainerControl)
        Dim clr As ColorPicker=new ColorPicker()
 
        container.Controls.Add(clr)
        clr.Location=container.ClientRectangle.Location
        container.ClientSize=clr.Size
    End If
End Sub

Related posts:

  1. How to Create Popup Menu or Toolbar Using Code
  2. How to dynamically display list of bars on menu
  3. How to selectively display Gallery items based on Gallery state, popup or inline
  4. How to popup menu with NotifyIcon
  5. How to Create Toolbars Using Code