Skip to content

DevExpress-Examples/winforms-assign-popupmenu-to-dropdownbutton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinForms Popup Menu - How to use a popup menu as the dropdown of DropDownButton

The WinForms DropDownButton control is a push button with an associated popup control. This example demonstrates how to display a popup menu when the drop-down button is clicked. The example demonstrates how to customize the DropDownButton at design-time and runtime.

Use the DropDownButton.DropDownControl property to assign a PopupMenu to a DropDownButton control.

private void InitDropDownButton() {
    // Creates the DropDownButton.
    DropDownButton dropDownButton = CreateDropDownButton("Button created at runtime", "MyButton", DropDownButtonExample.Properties.Resources.About, this.dropDownButton1.Size);
    dropDownButton.BringToFront();
    // Creates poup menu items.
    DevExpress.XtraBars.BarButtonItem item1 = CreateBarButtonItem("Item 1", "item1", 0);
    DevExpress.XtraBars.BarButtonItem item2 = CreateBarButtonItem("Item 2", "item2", 1);
    // Creates the popup menu and assigns it to the DropDownButton.
    dropDownButton.DropDownControl = CreatePopupMenu(new BarItem[] { item1, item2 }, this.barManager1, "MyPopupMenu");
}

Files to Review

Documentation