Gets or sets a value that indicates whether the menu item is visible on its parent menu.
[Visual Basic] Public Property Visible As Boolean [C#] public bool Visible {get; set;} [C++] public: __property bool get_Visible(); public: __property void set_Visible(bool); [JScript] public function get Visible() : Boolean; public function set Visible(Boolean);
true if the menu item will be made visible on the menu; false if the menu item is to be hidden.
You can use this property to modify a menu structure without having to merge menus or disable menus.
The following example creates a menu item, sets the caption, assigns a shortcut key, makes the menu item visible, and shows the shortcut key display for the menu item. The example assumes a MenuItem object has been created that is named MenuItem1.
[Visual Basic]
Public Sub SetupMyMenuItem() ' Create a menu item to use. Dim MenuItem1 = New MenuItem Set MenuItem1 = New MenuItem ' Set the Public Sub SetupMyMenuItem() ' Set the caption for the menu item. MenuItem1.Text = "&New" ' Assign a shortcut key. MenuItem1.Shortcut = Shortcut.CtrlN ' Make the menu item visible. MenuItem1.Visible = True ' Display the shortcutkey combination. MenuItem1.ShowShortcut = True End Subcaption for the menu item. MenuItem1.Text = "&New" ' Assign a shortcut key. MenuItem1.Shortcut = Shortcut.CtrlN ' Make the menu item invisible by default MenuItem1.Visible = False End Sub
MenuItem Class | MenuItem Members | System.WinForms Namespace