MenuItem.Text 屬性

定義

取得或設定值,指出功能表項目的標題。

public:
 property System::String ^ Text { System::String ^ get(); void set(System::String ^ value); };
public string Text { get; set; }
member this.Text : string with get, set
Public Property Text As String

屬性值

功能表項目的文字標題。

範例

下列程式代碼範例會建立功能表項、設定 標題、指派快捷鍵、讓功能表項顯示,以及顯示功能表項的快速鍵顯示。 這個範例需要 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

備註

當您為功能表項指定 標題 時,也可以在要當做訪問鍵的字元之前放置 '&' 來指定存取鍵。 例如,若要將 “File” 中的 “F” 指定為訪問鍵,您可以將功能表項的 標題 指定為 “&File”。 您可以使用這項功能來提供功能表的鍵盤流覽。

將此屬性設定為 「-「 會導致功能表項顯示為分隔符, (水平線) 而非標準選單項。

適用於

另請參閱