Context is VERY slow when there are a lot of items (> 100) in the menu

2 posts, 0 answers
  1. John Crumpton
    John Crumpton avatar
    12 posts
    Member since:
    Jul 2009

    Posted 09 Dec 2011 Link to this post

    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);

    showing the context menu...
    cm.Show(radChart1, new Point(0, 0));
  2. Jack
    Jack avatar
    2333 posts

    Posted 13 Dec 2011 Link to this post

    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"));
    RadMenuComboItem combo = new RadMenuComboItem();
    for (int i = 0; i < 200; i++)
        combo.Items.Add(new RadListDataItem("Item " + i));

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

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

Back to Top