Menu.MenuItems プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

メニューに格納された MenuItem オブジェクトのリストを表す System.Windows.Forms.Menu.MenuItemCollection。

このプロパティを使用して、現在メニューに格納されているメニュー項目のリストへの参照を取得できます。MainMenu オブジェクトと ContextMenu オブジェクトの場合、MenuItems プロパティにはコントロールの完全なメニュー構造が格納されています。MenuItem クラスの場合、MenuItems プロパティには MenuItem に関連付けられているサブメニュー項目のリストが格納されています。(このプロパティによって提供される) メニューのメニュー項目のコレクションへの参照を使用して、メニュー項目を追加したり削除したり、メニュー項目の合計数を決定したり、コレクションからメニュー項目のリストを削除できます。メニューのメニュー項目のコレクションの維持に関する詳細については、System.Windows.Forms.Menu.MenuItemCollection ドキュメントのトピックを参照してください。

派生クラス MainMenu のインスタンスを作成し、MenuItem オブジェクトのコレクションに MenuItem オブジェクトを追加するコード例を次に示します。この例で定義されるメソッドは、フォームのクラス内に記述し、そのフォーム クラスのメソッドから呼び出す必要があります。
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
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: 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.get_MenuItems().Add(menuItem1); // Assign mainMenu1 to the form. this.set_Menu(mainMenu1); } //InitializeMyMainMenu

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Menu クラス
Menu メンバ
System.Windows.Forms 名前空間
MainMenu クラス
ContextMenu クラス
MenuItem
System.Windows.Forms.Menu.MenuItemCollection
Weblioに収録されているすべての辞書からMenu.MenuItems プロパティを検索する場合は、下記のリンクをクリックしてください。

- Menu.MenuItems プロパティのページへのリンク