How to add a separator to a WinForms ContextMenu?
Solution 1:
I believe it's just a dash:
ContextMenu.MenuItems.Add("-");
Solution 2:
This works just as well as the dash, and i suspect the Winforms will translate the dash to a ToolStripSeparator. I for one think this solution is more obvious for anyone who has to maintain the code.
yourContextMenu.Items.Add(new ToolStripSeparator());
Solution 3:
In WPF:
ContextMenu.MenuItems.Add(new Separator());
Solution 4:
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.