MenuItem.Visible 属性

定义

获取或设置一个值,通过该值指示菜单项是否可见。

public:
 property bool Visible { bool get(); void set(bool value); };
public bool Visible { get; set; }
member this.Visible : bool with get, set
Public Property Visible As Boolean

属性值

Boolean

如果菜单项在菜单上为可见,则为 true;否则为 false。 默认值为 true

示例

下面的代码示例创建一个菜单项,设置标题,分配快捷键,使菜单项可见,并显示菜单项的快捷键显示。 该示例要求 MenuItem 已创建一 menuItem1个名为 ..

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;
   }
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;
}
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

注解

可以使用此属性来修改菜单结构,而无需合并菜单或禁用菜单。 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.

适用于