How to add sub menu items in contextmenustrip using C#4.0?

前端 未结 2 1447
天命终不由人
天命终不由人 2020-12-10 01:03

I have one contextmenustrip control associated with treenode. I have created one menu item in contextmenustrip manually in the form itself(for example named as \"Assign\").

2条回答
  •  离开以前
    2020-12-10 01:30

    To add an item, you would call

    myContextMenuStrip.Items.Add("Item title", null, myClickHandler);
    

    To add a sub-menu, you take an existing item and do the same to it:

    (myContextMenuStrip.Items[0] as ToolStripMenuItem).DropDownItems.Add(...)
    

提交回复
热议问题