Is there a Menu item maximum count?

  • Thread starter Thread starter Dean Slindee
  • Start date Start date
D

Dean Slindee

Is there a maximum number of menu items that can be added to a single form?
If there is no maximum, that would help eliminate one possible source of the
problem.

I had six main menu items in the menu bar. After adding about 500 submenu
items to the first four main menu items, the last two menu items have now
disappeared. They are still there in the generated component code, but do
not appear in the designer. I suspect that something got hosed during the
process of adding submenu items, and dragging submenu items around.

Here is one of a dozen similar pieces of problematic-looking (to me) code:
Me.mnuServiceFosterTableCaretaker.Index = -1

Me.mnuServiceFosterTableCaretaker.Text = "Caretaker Type"

Any suggestions?

Dean Slindee
 
Hello Dean,

Thanks for posting in the group.

now the question is: You have six main menu items in the menu bar. After
adding about 500 submenu to the first four main menu items, the last two
main menu items disappear. You want to know whether there is a maximum
count number of menu item in .NET winform application, right?

Based on my experience, there is no such limitation in .NET programming. I
did a quick test on a C# winform application and add 500 sub menu items to
the first menu. It won't affect other menus. The sample code is:

public void AddMenu()
{
MainMenu mnuFileMenu = new MainMenu();
this.Menu = mnuFileMenu;
MenuItem myMenuItemFile = new MenuItem("&File");
mnuFileMenu.MenuItems.Add(myMenuItemFile);
MenuItem myMenuItemEdit = new MenuItem("&Edit");
mnuFileMenu.MenuItems.Add(myMenuItemEdit);
MenuItem myMenuItemOption = new MenuItem("&Option");
mnuFileMenu.MenuItems.Add(myMenuItemOption);
MenuItem myMenuItemHelp = new MenuItem("&Help");
mnuFileMenu.MenuItems.Add(myMenuItemHelp);
MenuItem myMenuItemTest = new MenuItem("&Test");
mnuFileMenu.MenuItems.Add(myMenuItemTest);



MenuItem myMenuItemNew1 = new MenuItem("&New");
myMenuItemFile.MenuItems.Add(myMenuItemNew1);
MenuItem myMenuItemNew2 = new MenuItem("&New");
myMenuItemEdit.MenuItems.Add(myMenuItemNew2);
MenuItem myMenuItemNew3 = new MenuItem("&New");
myMenuItemOption.MenuItems.Add(myMenuItemNew3);
MenuItem myMenuItemNew4 = new MenuItem("&New");
myMenuItemHelp.MenuItems.Add(myMenuItemNew4);
MenuItem myMenuItemNew5= new MenuItem("&New");
myMenuItemTest.MenuItems.Add(myMenuItemNew5);


for (int i=0; i< 500; i++)
{
MenuItem myMenuSubItemTest = new MenuItem("&TestSubMenuItem"+i.ToString
());
myMenuItemFile.MenuItems.Add(myMenuSubItemTest);
}
}

I am not sure of why you need so many menu items. However, based on my
experience, this is not a convenient UI for users. I think it is better if
you could redesign the structure of them to see if you could merge some
setting in forms or somewhere.

If the problem still happens on your side, could you please create a small
repro sample and email it to me? I will look into it on my side. You can
reach me by removing online from my email address here.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Dean,

How is everything going? Based on my testing, there should not be such
limitations. If there is any we can do on it, please feel free to post here.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top