Alex Rivera | Logout

How to add a separator to a WinForms ContextMenu?

Asked 2009-08-28T23:24:32.010
114

Inside my control, I have:

ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add(new MenuItem("&Add Item", onAddSpeaker));
ContextMenu.MenuItems.Add(new MenuItem("&Edit Item", onEditSpeaker));
ContextMenu.MenuItems.Add(new MenuItem("&Delete Item", onDeleteSpeaker));
ContextMenu.MenuItems.Add( ??? );
ContextMenu.MenuItems.Add(new MenuItem("Cancel"));

How to add a separation line to this ContextMenu?

Edit
Report

1 Answer

8

If you are using the Designer, place a single hyphen "-" as text the same way you would name your menu items. After hitting enter, the separator will be created.

answered 2009-08-28T23:27:19.507

Your Answer