[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 906
  • Last Modified:

How to set size of Context Menu in C#?

I want to set size of te context menu, i.e. I want to set the no of items that should be displayed when we show context menu.
Does any body know how to achieve this??

regards
Paresh
0
paresh_vs
Asked:
paresh_vs
1 Solution
 
aacoolCommented:
The ContextMenu contains MenuItem objects. To hide or show specific menuItems, set the Visible property of the menu item. The contextmenu will show all the menu items that have Visible=true. There is no function to show a specific number of items, although writing one should be easy enough.

What's with this trend of awarding 20 points?

e.g.
    public void AddMenuItems(ContextMenu contextMenu1)
    {
     // Define the MenuItem objects to display for the TextBox.
     MenuItem menuItem1 = new MenuItem("&Copy");
     MenuItem menuItem2 = new MenuItem("&Find and Replace");
     MenuItem menuItem3 = new MenuItem("&Provide Input");
     menuItem3.Visible = false;

     // Clear all previously added MenuItems.
     contextMenu1.MenuItems.Clear();
     // Add MenuItems - menuItem3 will not be visible until Visible=True;
     contextMenu1.MenuItems.Add(menuItem1);
     contextMenu1.MenuItems.Add(menuItem2);
     contextMenu1.MenuItems.Add(menuItem3);
    }
0
 
msdixonCommented:
Don't spend 'em all in one place. (the points, that is.)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now