Search code examples
c#menustripsubitem

How to access to a subitem of a MenuStrip


I have a MenuStrip which have 3 items. The second item, has 7 items (10 if separators are considered items). The point is, I want to access to the item number 7 (again, item number 10 if separators are considered items) so I do this:

menuStrip.Items[1]...

and, by that way, I can access to the 2nd item of the Menu Strip, but the problem is that at this point I have no way to access to its childs Items. I need to do this because I have to use PerformClick() method of one of these subItems.

Notice that when I do menuStrip.Items[1]... I was expecting something like the options DropDown or DropDownItems but they don't appear and I don't know if I'm doing something wrong or missing something.

This is the hierarchy:

1.-MenuStrip

1.1.-File

1.1.1.-Close

1.2.-Agenda

1.2.1....

1.2.2....

1.2.3....

1.2.4....

1.2.5.-Separator1

1.2.6....

1.2.7.-Separator2

1.2.8....

1.2.9.-Separator3

1.2.10.-**ShowSummaryToolStripMenuItem** 
(this is the item that I want to access)

1.3.-Help

1.3.1....

1.3.2....

I wanted to add a pair of pics to show it better but apparently "I need at least 10 reputation to post images".

Really thanks for your attention and patience.

EDIT: I already found the solution by myself. I just didn't know that actually the MenuStrip(Sub)Item was an object by itself and I could work with it just using its name, that was the point :D


Solution

  • How about naming the Sub-MenuItems?

    Then you could easily access on them