Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

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").Now i want to add sub menu items whenever user clicks this Assign item,it will create a list of users name as a sub menu item with checked or unchecked option.

For example, once user clicked Assign then i want to show the user name dynamically...

saravanan
suresh
murali

how i do it.
Please Guide me to get out of this issue...
Posted

ToolStripMenuItem ToolStrip;

private void CreateSubMenu(string text)
        {
            ToolStrip = new ToolStripMenuItem(text);
            ToolStrip.Text = text;
            ToolStrip.Click += new EventHandler(Item_Click);
            ToolStrip.CheckOnClick = true;
            showNoteToolStripMenuItem.DropDown.Items.Add(newnote);
 //showNoteToolStripMenuItem is Main ToolStrip
}

This is a way to add SubMenuItems to MenuStrip like a similiar way you can add sub menus to contextmenu because ContextMenuStrip is formed from ToolStripMenus.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900