Hiding Menu Items on Windows Forms
Hiding menu items is a way to control the user interface of your application and restrict user commands. Often, it is desirable to hide an entire menu when all of the menu items on it are unavailable. This presents fewer distractions for the user. Furthermore, it is imperative to hide AND disable the menu, as hiding alone does not prevent access to a menu command via shortcut key. For more information about disabling menu items, see Disabling Items on Windows Forms Menus.
To hide a menu item at design time
- With the menu item selected in the Menu Designer, set its Visible property to false.
Note When the top-level menu item in a given menu is hidden (its Visible property set to false), all menu items within that menu are hidden.
To hide a menu item programmatically
- Within the method where you set the properties of the menu item (such as Text), add code to set the Visible property to false:
' Visual Basic MenuItem3.Visible = False // C# menuItem3.Visible = false; // C++ menuItem3->Visible = false;