DXPopupMenu.MenuViewType Property
Gets or sets how the current menu is displayed (as a menu, floating bar or RibbonMiniToolbar).
Namespace: DevExpress.Utils.Menu
Assembly: DevExpress.Utils.v24.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
MenuViewType | Menu | A MenuViewType value |
Available values:
Name | Description |
---|---|
Menu | A menu is displayed as a regular popup menu. |
Toolbar | A menu is displayed as a popup bar. |
RibbonMiniToolbar | A menu is displayed as a RibbonMiniToolbar. |
Remarks
A DXPopupMenu can be displayed as a regular menu, popup bar or RibbonMiniToolbar.
This can be accomplished by changing the menu’s display mode via the MenuViewType property and using a corresponding menu manager (this manager is responsible for displaying a DXPopupMenu in a specific manner). Note that only changing the display mode via the MenuViewType property is not enough. You also need to use a corresponding menu manager that is passed to the DXPopupMenu’s IDXDropDownControl.Show method.
The following menu managers are available:
SkinMenuManager - This manager displays a DXPopupMenu as a regular menu.
DXEditMenuItem objects are not supported by the SkinMenuManager. These items, which are used to embed in-place editors into popup controls, are presented only in text (without edit boxes).
A DXButtonGroupItem object, which is used to present a set of linked buttons, is displayed as a sub-menu by the SkinMenuManager.
BarManager - This manager displays a DXPopupMenu as a popup bar.
RibbonControl - This manager displays a DXPopupMenu as a RibbonMiniToolbar.
Example 1
// Display a DXPopupMenu as a regular menu
UserLookAndFeel lf = UserLookAndFeel.Default;
Control parentControl = this;
Point pt;
DXPopupMenu dxPopupMenu = new DXPopupMenu();
//...
dxPopupMenu.MenuViewType = MenuViewType.Menu;
dxPopupMenu.ShowPopup(parentControl, pt);
//or
((IDXDropDownControl)dxPopupMenu).Show(new SkinMenuManager(lf), parentControl, pt);
Example 2
// Display a DXPopupMenu as a popup bar
Control parentControl = this;
Point pt;
DXPopupMenu dxPopupMenu = new DXPopupMenu();
//...
dxPopupMenu.MenuViewType = MenuViewType.Toolbar;
dxPopupMenu.ShowPopup(parentControl, pt);
//or
((IDXDropDownControl)dxPopupMenu).Show(barManager1, parentControl, pt);
Example 3
// Display a DXPopupMenu as a RibbonMiniToolbar
Control parentControl = this;
Point pt;
DXPopupMenu dxPopupMenu = new DXPopupMenu();
//...
dxPopupMenu.MenuViewType = MenuViewType.RibbonMiniToolbar;
dxPopupMenu.ShowPopup(parentControl, pt);
//or
((IDXDropDownControl)dxPopupMenu).Show(RibbonControl1, parentControl, pt);
Example
This example shows how to display DXPopupMenu as a regular menu, popup bar or RibbonMiniToolbar. To change a menu's display mode, the MenuViewType property is used.To display DXPopupMenu as a popup bar, you need to set the MenuViewType property to Toolbar and also pass a BarManager object to the DXPopupMenu.Show method. Similarly, to display DXPopupMenu as RibbonMiniToolbar, you need to set the MenuViewType property to Toolbar and also pass a RibbonControl object to the DXPopupMenu.Show method.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Utils.Menu;
using DevExpress.XtraEditors.Repository;
namespace DXPopupMenu_DisplayMode {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
InitPopupMenu();
}
protected virtual void InitPopupMenu() {
RepositoryItemComboBox riEditComboBox = new RepositoryItemComboBox();
riEditComboBox.Items.Add("item1");
riEditComboBox.Items.Add("item2");
riEditComboBox.Items.Add("item3");
riEditComboBox.Items.Add("item4");
riEditComboBox.Items.Add("item5");
RepositoryItemDateEdit riDateEdit = new RepositoryItemDateEdit();
menu = new DXPopupMenu();
menu.Items.Add(new DXMenuItem("Cut", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Cut_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Cut_32x32, null));
menu.Items.Add(new DXMenuItem("Copy", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Copy_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Copy_32x32, null));
menu.Items.Add(new DXMenuItem("Paste", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Paste_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Paste_32x32, null));
menu.Items.Add(new DXEditMenuItem("ComboBox", riEditComboBox, null, null, null, 100, -1));
menu.Items.Add(new DXEditMenuItem("DateEdit", riDateEdit, null, null, null, 100, -1));
DXButtonGroupItem group1 = new DXButtonGroupItem();
group1.Caption = "Button Group 1";
group1.Items.Add(new DXMenuItem("Open", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Open_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Open_32x32, null));
group1.Items.Add(new DXMenuItem("Save", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Save_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Save_32x32, null));
group1.Items.Add(new DXMenuItem("Save All", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.SaveAll_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.SaveAll_32x32, null));
DXButtonGroupItem group2 = new DXButtonGroupItem();
group2.Caption = "Button Group 2";
group2.Items.Add(new DXMenuItem("Edit", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Edit_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Edit_32x32, null));
group2.Items.Add(new DXMenuItem("Delete", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Delete_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Delete_32x32, null));
group2.Items.Add(new DXMenuItem("Print", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Print_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Print_32x32, null));
DXButtonGroupItem group3 = new DXButtonGroupItem();
group3.Caption = "Button Group 3";
group3.Items.Add(new DXMenuItem("Close", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Close_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Close_32x32, null));
group3.Items.Add(new DXMenuItem("Delete", new EventHandler(OnItemClick), DXPopupMenu_DisplayMode.Properties.Resources.Delete_16x16, null, DXPopupMenu_DisplayMode.Properties.Resources.Delete_32x32, null));
menu.Items.Add(group1);
menu.Items.Add(group2);
menu.Items.Add(group3);
}
void OnItemClick(object sender, EventArgs e) { }
DXPopupMenu menu;
private void btnDisplayAsRegularMenu_Click(object sender, EventArgs e) {
SimpleForm form = new SimpleForm();
form.PopupMenu = menu;
form.Show();
}
private void btnDisplayAsPopupBar_Click(object sender, EventArgs e) {
BarsForm form = new BarsForm();
form.PopupMenu = menu;
form.Show();
}
private void btnDisplayAsRibbonMiniToolbar_Click(object sender, EventArgs e) {
RibbonForm1 form = new RibbonForm1();
form.PopupMenu = menu;
form.Show();
}
}
}