Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Menu, Application Menu, Context Menu > Context Menu.show is VERY slow when there are a lot of items (> 100) in the menu

Not answered Context Menu.show is VERY slow when there are a lot of items (> 100) in the menu

Feed from this thread
  • Posted on Dec 9, 2011 (permalink)

    I know it's an unusual situation, but I have a case where I'm adding the items to the context menu's items collection in code... I build the context menu when the form loads. When I call the .show method, it works fine when there are not many items in the .items collection... maybe >20. In many cases, I have 100+ and it effectivly does not work.... minutes later, the context menu finally pops.

    I replaced the control w/ the free one that ships from Microsoft and it works fine with no other changes to the code.

    In the form's load event....
    cm = new RadContextMenu();
    foreach (string g in groups)
          {
              RadMenuItem mnu = new RadMenuItem();
              mnu.Text = g;
              mnu.Click += new EventHandler(cmclick);
              cm.Items.Add(mnu);
          }

    showing the context menu...
    cm.Show(radChart1, new Point(0, 0));

    Reply

  • Jack Jack admin's avatar

    Posted on Dec 13, 2011 (permalink)

    Hi John,

    Thank you for contacting us.

    RadMenu is not designed to show a large number of items and it is normal to observe slow performance in such cases. The issue is caused by the fact that RadMenu creates visual elements for all menu items. However, there are other controls such as RadListControl, RadListView or RadGridView which support UI virtualization and the items count does not affect their performance. 

    The following sample demonstrates how to use RadDropDownList inside RadMenu to show 200 items:
    RadMenu menu = new RadMenu();
    menu.Dock = DockStyle.None;
    menu.AutoSize = false;
    menu.Location = new Point(50, 50);
    menu.Size = new Size(200, 20);
    menu.Items.Add(new RadMenuItem("File"));
    this.Controls.Add(menu);
     
    RadMenuComboItem combo = new RadMenuComboItem();
    for (int i = 0; i < 200; i++)
    {
        combo.Items.Add(new RadListDataItem("Item " + i));
    }
    menu.Items.Add(combo);

    If you have further questions, please do not hesitate to write back.
     
    Best wishes,
    Jack
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Menu, Application Menu, Context Menu > Context Menu.show is VERY slow when there are a lot of items (> 100) in the menu
Related resources for "Context Menu.show is VERY slow when there are a lot of items (> 100) in the menu"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]