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

備註

您可以使用這個屬性來修改功能表結構,而不需要合併功能表或停用功能表。 例如,如果您想要從應用程式的功能表隱藏完整的功能區段,您可以將此屬性設定為 false 來隱藏使用者。

適用於