How to add a separator to a WinForms ContextMenu?

Adam Pierce picture Adam Pierce · Aug 29, 2009 · Viewed 74.3k times · Source

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?

Answer

SqlRyan picture SqlRyan · Aug 29, 2009

I believe it's just a dash:

ContextMenu.MenuItems.Add("-");