将分隔符添加到托盘图标上下文菜单中

时间:2013-05-08 20:41:58

标签: c# winforms .net-4.5

我想在系统托盘图标上的上下文菜单项之间添加分隔符。这是我的代码:

    ContextMenu cm = new ContextMenu();
    cm.MenuItems.Add("Resume", new EventHandler(MenuResume_Click));
    cm.MenuItems.Add(); // Here i want the divider
    cm.MenuItems.Add("Logout", new EventHandler(BTNExit_Click));
    cm.MenuItems.Add("Logout and Quit", new EventHandler(BTNExit_Compl));

    this.Hide();
    NIControlPanel.Visible = true;
    NIControlPanel.ContextMenu = cm;

像这样的分频器>> http://i.stack.imgur.com/pgksW.png

1 个答案:

答案 0 :(得分:1)

cm.MenuItems.Add(new ToolStripSeparator());应该工作