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

Show a popup menu as a DropDownButton control's dropdown.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Show a popup menu as a DropDownButton control's dropdown.

License:Other


Languages

Language:C# 50.1%Language:Visual Basic .NET 49.9%