语言

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

属性值

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

注解

可以使用此属性修改菜单结构,而无需合并菜单或禁用菜单。 例如,如果要从应用程序的菜单中隐藏完整的功能部分,可以通过将此属性设置为 来将其从用户中隐藏。

适用于