How to add a separator to a WinForms ContextMenu?

前端 未结 8 1485
暖寄归人
暖寄归人 2020-12-29 00:47

Inside my control, I have:

ContextMenu = new ContextMenu();
ContextMenu.MenuItems.Add(new MenuItem(\"&Add Item\", onAddSpeaker));
ContextMenu.MenuItems.A         


        
8条回答
  •  不思量自难忘°
    2020-12-29 01:14

    Perhaps in later versions of Visual Studio they made this simpler. I'm using VS 2012. You can add a separator via the forms designer. 1) Select/Create a MenuStrip. 2) On "Type Here", right mouse. 3) Select "Insert". 4) Select "Separator". 5) Drag the new separator to the text you want it to be above. Done.

提交回复
热议问题