Grouping Bar Items in Windows Forms PopupMenu

4 Feb 20251 minute to read

Grouping allows to add separator between a collection of bar items which are relevant to one another. To group the required bar items, the SeparatorIndices property of the associated ParentBarItem is used.

The below code snippets add a Separator to the PopupMenu control.

this.parentBarItem1.SeparatorIndices.AddRange(new int[] { 1, 4});
Me.parentBarItem1.SeparatorIndices.AddRange(New Integer() { 1, 4})

Grouping

Grouping can also be done by using the below mentioned methods.

  • BeginGroupAt : Begins the categorization (grouping) of items immediately before the BarItem instance specified.

  • RemoveGroupAt : Ends the categorization (grouping) of items immediately before the BarItem instance specified.

  • IsGroupBeginning : Returns a boolean value whether the specified bar item instance is at the beginning of the grouping or not.

The below code snippets will explain how to set grouping by using the methods.

this.parentBarItem1.BeginGroupAt(this.barItem2);
this.parentBarItem1.BeginGroupAt(this.parentBarItem2);
this.parentBarItem1.RemoveGroupAt(this.barItem2);
Me.parentBarItem1.BeginGroupAt(Me.barItem2)
Me.parentBarItem1.BeginGroupAt(Me.parentBarItem2)
Me.parentBarItem1.RemoveGroupAt(Me.barItem2)

Grouping