This is a migrated thread and some comments may be shown as answers.

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

1 Answer 324 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
John Crumpton
Top achievements
Rank 1
John Crumpton asked on 09 Dec 2011, 06:54 PM
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));

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 13 Dec 2011, 04:52 PM
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.

Tags
ContextMenu
Asked by
John Crumpton
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or