I got a menu item, which when you press different toolstripmenu items show. But I want to add subtoolstripmenu items to a toolstripmenuitem. This is how I thought it would work:
ToolStripMenuItem[] items = new ToolStripMenuItem[10];
for (int i=0;i<10;i++)
{
items[i] = new ToolStripMenuItem();
items[i].Name = i;
items[i].Text = i;
items[i].Tag = i;
items[i].Click += new EventHandler(MenuItemClickHandler);
}
toolStripMenuItem1.DropDownItems[2].AddRange(items); //not possible
toolStripMenuItem1.DropDownItems.AddRange(items); // possible
Sadly it only works when I use toolStripMenuItem1.DropDownItems.AddRange(items);
but not when I use toolStripMenuItem1.DropDownItems[2].AddRange(items);
. Anyone any idea how to do this?
I dont want it to expand at the red cross, i want the green circle: https://i.stack.imgur.com/jFT1v.jpg
LarsTech's comment is correct. Replace the last 2 lines with: