MenuItem array index

I have a menu with the following structure:

MenuX MenuA MenuB Separator MenuList // This is the menu item array start element, which has an index set to 0 in the menu designer
Elements are appended at runtime by doing

Dim item As MenuItem = New MenuList()

Now when I implement the menu handler for MenuList, the index argument in the menu handler is not the position of the item within the menu item array, but the one within the parent menu item (in this case MenuX). For the above example this looks like this:

  • if the user chooses MenuList(0), the index is 3 (not 0)
  • if the user chooses MenuList(1), the index is 4 (not 1)
  • etc.

The docs say:

… which is kind of ambiguous. “number of” could mean both: the index within the menu item array and the index within the parent menu item. To me it would seem natural to get the index within the menu item array in the menu handler.

Your code is adding MenuItems to the MenuX menu, so the indexing is correct.

If you want to add submenu items to MenuList, you’ll need to make it a Submenu and then put a menu item array in it.