how to add sub-items to context menu items

W

weird0

private void treeView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right) // detect Right
click
{
TreeNode selectedNode = treeView1.GetNodeAt(e.X,
e.Y);
ContextMenu cMenu = new ContextMenu();
MenuItem menuItem = new MenuItem("Set Evidence",new
EventHandler(popup));
// want to add two sub-items Item1 and Item2 .... How ?
cMenu.MenuItems.Add(menuItem);
cMenu.Show(this,new Point(e.X+50,e.Y+30));

}
}
 
N

Nicholas Paldino [.NET/C# MVP]

You can access the MenuItems property on the MenuItem instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top