How to set size of Context Menu in C#?

Posted on 2004-11-23
Last Modified: 2008-03-17
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??

Question by:paresh_vs
    LVL 3

    Accepted Solution

    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?

        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.
         // Add MenuItems - menuItem3 will not be visible until Visible=True;
    LVL 9

    Expert Comment

    Don't spend 'em all in one place. (the points, that is.)

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now