Articles in this section
Category / Section

How to populate the WinForms PopupMenu?

2 mins read

Populate a PopupMenu

The first thing to populate a PopupMenu is to set the ParentBarItem property. This can be achieved in one of the following ways:

Using the Designer

There are 2 scenarios tp populate the PopupMenu:

Case 1: You have a BarManager (ChildFrameBarManager or MainFrameBarManager) in your form. In this case, you might want to use a ParentBarItem in the BarManager as your PopupMenu’s ParentBarItem too. If so, just select the appropriate ParentBarItem in the PopupMenu’s property browser.

Once you do so, you can select the "Customize" verb in the PopupMenu designer to invoke the "PopupMenu Form" designer to view the PopupMenu that you will be designing. You can now just drag-and-drop items from your BarManager "Customize" dialog into the PopupMenu. To delete an item, right click on it and select "Delete". To introduce grouping, right-click on the item and select "Begin A Group".

If you want to use a ParentBarItem that is not contained within a BarManager, have a look at Case 2.

Case 2: You do not have a BarManager in your form. If you already have a ParentBarItem that you want to use in your PopupMenu then just select it in the Property browser. If not, select the "Add Default ParentBarItem" verb in the PopupMenu designer. This will create a new ParentBarItem and use it in the PopupMenu.

You can now populate the PopupMenu by editing the ParentBarItem’s Items list (via its Collection Editor). You can see the popup getting designed through the "Customize" verb, but you cannot visually edit it like in the above case.

Through Code

Populating the menus in code is simple:

C#

this.popupMenu1 = new Syncfusion.Windows.Forms.Tools.PopupMenu();
this.editMenu = new Syncfusion.Windows.Forms.Tools.ParentBarItem();
this.editMenu.Text = "&Edit";
this.editMenu.Items.AddRange(new BarItem[] {this.cutItem, this.copyItem});
this.popupMenu1.ParentBarItem = this.editMenu;

VB

Me.popupMenu1 = New Syncfusion.Windows.Forms.Tools.PopupMenu()
Me.editMenu = New Syncfusion.Windows.Forms.Tools.ParentBarItem()
Me.editMenu.Text = "&Edit"
Me.editMenu.Items.AddRange(New BarItem() {Me.cutItem, Me.copyItem})
Me.popupMenu1.ParentBarItem = Me.editMenu

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied