MenuItem.CloneMenu 메서드

정의

MenuItem의 복사본을 만듭니다.

오버로드

CloneMenu(MenuItem)

지정된 MenuItem의 복사본을 만듭니다.

CloneMenu()

현재 MenuItem의 복사본을 만듭니다.

CloneMenu(MenuItem)

지정된 MenuItem의 복사본을 만듭니다.

protected:
 void CloneMenu(System::Windows::Forms::MenuItem ^ itemSrc);
protected void CloneMenu (System.Windows.Forms.MenuItem itemSrc);
override this.CloneMenu : System.Windows.Forms.MenuItem -> unit
Protected Sub CloneMenu (itemSrc As MenuItem)

매개 변수

itemSrc
MenuItem

복사할 메뉴 항목을 나타내는 MenuItem입니다.

예제

다음 코드 예제에서는 새 초기화 MenuItem 기존 복사본을 사용 하 여 MenuItem 에서 사용 되는 MainMenu 양식의 합니다. 이 코드는 다음 복제 된 추가 MenuItemContextMenu 양식의 합니다. 이 예제에서는 MenuItem 이미 생성 되어 명명 된 menuItem1 하 고는 ContextMenu 컨트롤을 만들어야 라는 contextMenu1합니다.

public:
   void CloneMyMenu()
   {
      // Clone the existing MenuItem into the new MenuItem.
      MenuItem^ tempMenuItem = menuItem1->CloneMenu();
      
      // Assign the cloned MenuItem to the ContextMenu.
      contextMenu1->MenuItems->Add( tempMenuItem );
   }
public void CloneMyMenu()
{
   // Clone the existing MenuItem into the new MenuItem.
   MenuItem tempMenuItem = menuItem1.CloneMenu();
 
   // Assign the cloned MenuItem to the ContextMenu.
   contextMenu1.MenuItems.Add(tempMenuItem);
}
Public Sub CloneMyMenu()
    ' Clone the existing MenuItem into the new MenuItem.
    Dim tempMenuItem As MenuItem = menuItem1.CloneMenu()
       
    ' Assign the cloned MenuItem to the ContextMenu.
    contextMenu1.MenuItems.Add(tempMenuItem)
End Sub

설명

애플리케이션 내에서 이미 만든 바로 가기 메뉴 또는 다른 메뉴 구조 사용에 대 한 메뉴 항목의 복사본을 만드는이 메서드를 호출 합니다. 이 버전의 CloneMenu 특정을 지정할 수 있습니다 MenuItem 메서드를 호출 하는 메뉴 항목 대신 복사 합니다. 이 메서드를 사용 하 여 새 MenuItem 개체의 다른 복사본으로 MenuItem입니다. 메뉴 항목을 복제 되는 경우 원래 메뉴 항목에 지정 된 모든 이벤트 처리기는 메뉴 항목의 복제 된 버전에서 작동 계속 됩니다. 예를 들어 사용자가 만든를 MenuItem 및 연결 된 해당 Click 이벤트 처리기에는 이벤트입니다. 메뉴 항목이 복제 되는 경우 복제 된 메뉴 항목은 동일한 이벤트 처리기를 호출 합니다.

적용 대상

CloneMenu()

현재 MenuItem의 복사본을 만듭니다.

public:
 virtual System::Windows::Forms::MenuItem ^ CloneMenu();
public virtual System.Windows.Forms.MenuItem CloneMenu ();
override this.CloneMenu : unit -> System.Windows.Forms.MenuItem
Public Overridable Function CloneMenu () As MenuItem

반환

복제된 메뉴 항목을 나타내는 MenuItem입니다.

예제

다음 코드 예제에서는 복제본을 MenuItem 에 표시 된 ContextMenu. 예제에는 필요를 MenuItem 있는 MainMenu 이름의 양식의 menuItem1 하 고를 ContextMenu 라는 개체 contextMenu1 폼에 있는.

public:
   void CloneMyMenu()
   {
      // Clone the menu item and add it to the collection for the shortcut menu.
      contextMenu1->MenuItems->Add( menuItem1->CloneMenu() );
   }
public void CloneMyMenu()
{
   // Clone the menu item and add it to the collection for the shortcut menu.
   contextMenu1.MenuItems.Add(menuItem1.CloneMenu());
}
Public Sub CloneMyMenu()

    ' Clone the menu item and add it to the collection for the shortcut menu.
    contextMenu1.MenuItems.Add(menuItem1.CloneMenu())
    
End Sub

설명

MenuItem 개체의 복사본을 획득 하지 않는 한 둘 이상의 위치에서 사용할 수 없습니다는 MenuItem합니다. 사용 하기 위해이 메뉴 항목의 복사본을 만들려면이 메서드를 호출할 수는 ContextMenu, MainMenu, 또는 기타 MenuItem 애플리케이션 내에서. 메뉴 항목을 복제 되는 경우 원래 메뉴 항목에 지정 된 모든 이벤트 처리기는 메뉴 항목의 복제 된 버전에서 작동 계속 됩니다. 예를 들어 사용자가 만든를 MenuItem 및 연결 된 해당 Click 이벤트 처리기에는 이벤트입니다. 메뉴 항목이 복제 되는 경우 복제 된 메뉴 항목은 동일한 이벤트 처리기를 호출 합니다.

적용 대상