Menu.MenuItems プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メニューに関連付けられている MenuItem オブジェクトのコレクションを示す値を取得します。
public:
property System::Windows::Forms::Menu::MenuItemCollection ^ MenuItems { System::Windows::Forms::Menu::MenuItemCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.Menu.MenuItemCollection MenuItems { get; }
[<System.ComponentModel.Browsable(false)>]
member this.MenuItems : System.Windows.Forms.Menu.MenuItemCollection
Public ReadOnly Property MenuItems As Menu.MenuItemCollection
プロパティ値
メニューに格納されているMenuItem オブジェクトの一覧を表すMenu.MenuItemCollection。
- 属性
例
次のコード例では、派生クラスのインスタンスを作成し、 MainMenuし、 MenuItem オブジェクトを MenuItem オブジェクトのコレクションに追加します。 この例では、この例で定義されているメソッドがフォームのクラス内にあり、そのフォーム クラスのメソッドによって呼び出されている必要があります。
private:
void InitializeMyMainMenu()
{
// Create the MainMenu and the MenuItem to add.
MainMenu^ mainMenu1 = gcnew MainMenu;
MenuItem^ menuItem1 = gcnew MenuItem( "&File" );
/* Use the MenuItems property to call the Add method
to add the MenuItem to the MainMenu menu item collection. */
mainMenu1->MenuItems->Add( menuItem1 );
// Assign mainMenu1 to the form.
this->Menu = mainMenu1;
}
private void InitializeMyMainMenu()
{
// Create the MainMenu and the MenuItem to add.
MainMenu mainMenu1 = new MainMenu();
MenuItem menuItem1 = new MenuItem("&File");
/* Use the MenuItems property to call the Add method
to add the MenuItem to the MainMenu menu item collection. */
mainMenu1.MenuItems.Add (menuItem1);
// Assign mainMenu1 to the form.
this.Menu = mainMenu1;
}
Private Sub InitializeMyMainMenu()
' Create the MainMenu and the MenuItem to add.
Dim mainMenu1 As New MainMenu()
Dim menuItem1 As New MenuItem("&File")
' Use the MenuItems property to call the Add method
' to add the MenuItem to the MainMenu menu item collection.
mainMenu1.MenuItems.Add(menuItem1)
' Assign mainMenu1 to the form.
Me.Menu = mainMenu1
End Sub
注釈
このプロパティを使用すると、現在メニューに格納されているメニュー項目の一覧への参照を取得できます。 MainMenuオブジェクトとContextMenu オブジェクトの場合、MenuItems プロパティにはコントロール内のメニュー構造全体が含まれます。 MenuItem クラスの場合、MenuItems プロパティには、MenuItemに関連付けられているサブメニュー項目の一覧が含まれます。 (このプロパティによって提供される) メニューのメニュー項目のコレクションへの参照を使用すると、メニュー項目の追加と削除、メニュー項目の合計数の決定、およびコレクションからのメニュー項目の一覧のクリアを行うことができます。 メニューのメニュー項目コレクションの管理の詳細については、 System.Windows.Forms.Menu.MenuItemCollection ドキュメントを参照してください。