Export (0) Print
Expand All

MenuItem.Visible Property

Gets or sets a value indicating whether the menu item is visible.

[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);

Property Value

true if the menu item will be made visible on the menu; otherwise, false. The default is true.

Remarks

You can use this property to modify a menu structure without having to merge menus or disable menus. For example, if you want to hide a complete section of functionality from the menus for your application, you can hide them from the user by setting this property to false.

Example

[Visual Basic, C#, C++] 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()
    ' 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 shortcut key combination.
    menuItem1.ShowShortcut = True
End Sub


[C#] 
public void 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 shortcut key combination.
   menuItem1.ShowShortcut = true;
}
  

[C++] 
public:
 void SetupMyMenuItem()
 {
    // Set the caption for the menu item.
    menuItem1->Text = S"&New";
    // Assign a shortcut key.
    menuItem1->Shortcut = Shortcut::CtrlN;
    // Make the menu item visible.
    menuItem1->Visible = true;
    // Display the shortcut key combination.
    menuItem1->ShowShortcut = true;
 }
   

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

MenuItem Class | MenuItem Members | System.Windows.Forms Namespace

Show:
© 2014 Microsoft