語言

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

備註

你可以利用這個特性修改選單結構,而不必合併選單或停用選單。 例如,如果你想在應用程式選單中隱藏整個功能區段,可以透過將此屬性 false設為 來隱藏。

適用於