Menu.MenuItems 속성

정의

해당 메뉴와 연결된 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

속성 값

Menu.MenuItemCollection

메뉴에 저장된 Menu.MenuItemCollection 개체의 목록을 나타내는 MenuItem입니다.

특성

예제

다음 코드 예제에서는 파생 클래스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

설명

이 속성을 사용 하 여 메뉴에 현재 저장 된 메뉴 항목 목록에 대 한 참조를 가져올 수 있습니다. 개체의 ContextMenu 경우 MainMenu 속성에는 MenuItems 컨트롤의 전체 메뉴 구조가 포함됩니다. 클래스의 MenuItem 경우 속성에는 MenuItems .와 연결된 하위 메뉴 항목 목록이 포함됩니다 MenuItem. 메뉴의 메뉴 항목 컬렉션에 대한 참조를 사용하여(이 속성에서 제공) 메뉴 항목을 추가 및 제거하고, 총 메뉴 항목 수를 확인하고, 컬렉션에서 메뉴 항목 목록을 지울 수 있습니다. 메뉴의 메뉴 항목 컬렉션을 유지 관리하는 방법에 대한 자세한 내용은 설명서를 참조 System.Windows.Forms.Menu.MenuItemCollection 하세요.

적용 대상

추가 정보