How to Add ColorUI Control to a Popup Menu in ColorUI

13 Aug 20261 minute to read

To add ColorUIControl to a PopupMenu, we need to use PopupMenu, PopupControlContainer. Follow the below steps to add a ColorUIControl to a popup menu.

  1. Drag and drop a ColorUIControl, a PopupMenu control, a PopupControlContainer control, a label control and a Panel control onto the form. Place the ColorUIControl inside the PopupControlContainer and the label inside the panel control.
  2. Right click PopupMenu and select ‘Add Default ParentBarItem” from the verbs.

    ColorUIControl placed inside PopupControlContainer

  3. In the property grid of PopupMenu, expand ParentBarItem, then add a DropDownBarItem to the ParentBarItem using BarItem Collection Editor. Also set the PopupControlContainer as the DropDownBarItem’s PopupControlContainer as shown in the image below.

    DropDownBarItem added to ParentBarItem in PopupMenu

  4. In the MouseUp event of the Panel control call the PopupMenu.Show method.

    private void panel1_MouseUp(object sender, MouseEventArgs e)
    {
    	this.popupMenu1.Show(this.panel1, new Point(e.X, e.Y));
    }
    Private Sub panel1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
    Me.popupMenu1.Show(Me.panel1, New Point(e.X, e.Y))
    End Sub

    PopupMenu shown on the Panel control

NOTE

You can close the popup whenever a color is selected at run time. This is done using ColorUIControl.ColorSelected Event.