ToolStripManager.Merge 메서드

정의

ToolStrip 컨트롤을 결합합니다.

오버로드

Merge(ToolStrip, String)

같은 형식의 두 ToolStrip 개체를 결합합니다.

Merge(ToolStrip, ToolStrip)

다른 형식의 두 ToolStrip 개체를 결합합니다.

Merge(ToolStrip, String)

같은 형식의 두 ToolStrip 개체를 결합합니다.

public:
 static bool Merge(System::Windows::Forms::ToolStrip ^ sourceToolStrip, System::String ^ targetName);
public static bool Merge (System.Windows.Forms.ToolStrip sourceToolStrip, string targetName);
static member Merge : System.Windows.Forms.ToolStrip * string -> bool
Public Shared Function Merge (sourceToolStrip As ToolStrip, targetName As String) As Boolean

매개 변수

sourceToolStrip
ToolStrip

targetName 매개 변수에서 참조하는 ToolStrip과 결합할 ToolStrip입니다.

targetName
String

sourceToolStrip 매개 변수에서 참조하는 ToolStrip을 받는 ToolStrip의 이름입니다.

반환

Boolean

병합이 성공적으로 수행되면 true이고, 그렇지 않으면 false입니다.

예외

sourceToolStrip 또는 targetNamenull인 경우

sourceToolStrip 또는 targetName은 동일한 ToolStrip을 가리킵니다.

설명

사용 합니다 ToolStripManager.Merge 결합 하는 방법 ToolStrip 등의 동일한 개체 입력 ToolStrip 다른 개체 ToolStrip 개체를 MenuStrip 다른 개체 MenuStrip 개체 및 등입니다.

사용 된 ToolStripManager.Merge 결합 하는 방법 ToolStrip 다른 유형의 개체입니다.

합니다 ToolStrip.AllowMerge 속성으로 설정 되어 있어야 true 둘 다에 대해 ToolStrip 개체 및 원본 / 대상 형식의 동일 해야 하거나이 메서드는 반환 false합니다.

참고

두 개 있는 경우 MenuStrip 설정 하는 MDI 자식 폼의 컨트롤 IsMdiContainertrue 부모 폼 병합 중 하나만 내용의 MenuStrip 컨트롤입니다. 사용 하 여 Merge 내용을 병합 하 여 추가 자식 MenuStrip MDI 부모 폼의 컨트롤입니다.

추가 정보

적용 대상

Merge(ToolStrip, ToolStrip)

다른 형식의 두 ToolStrip 개체를 결합합니다.

public:
 static bool Merge(System::Windows::Forms::ToolStrip ^ sourceToolStrip, System::Windows::Forms::ToolStrip ^ targetToolStrip);
public static bool Merge (System.Windows.Forms.ToolStrip sourceToolStrip, System.Windows.Forms.ToolStrip targetToolStrip);
static member Merge : System.Windows.Forms.ToolStrip * System.Windows.Forms.ToolStrip -> bool
Public Shared Function Merge (sourceToolStrip As ToolStrip, targetToolStrip As ToolStrip) As Boolean

매개 변수

sourceToolStrip
ToolStrip

targetToolStrip 매개 변수에서 참조하는 ToolStrip과 결합할 ToolStrip입니다.

targetToolStrip
ToolStrip

sourceToolStrip 매개 변수에서 참조하는 ToolStrip을 받는 ToolStrip입니다.

반환

Boolean

병합이 성공적으로 수행되면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 지정 된 선택에 따라 메뉴 항목을 병합 합니다. 이 예제는에서 사용할 수 있는 보다 큰 예제의 일부는 ToolStripManager 클래스 개요입니다.

private MergeSample CurrentSample
{
    get { return currentSample; }
    set
    {
        if (currentSample != value)
        {
            bool resetRequired = false;

            if (currentSample == MergeSample.MatchOnly)
            {
                resetRequired = true;
            }
            currentSample = value;
            // Undo previous merge, if any.
            ToolStripManager.RevertMerge(cmsBase, cmsItemsToMerge);
            if (resetRequired)
            {
                RebuildItemsToMerge();
            }

            switch (currentSample)
            {
                case MergeSample.None:
                    return;
                case MergeSample.Append:
                    ScenarioText = "This sample adds items to the end of the list using MergeAction.Append.\r\n\r\nThis is the default setting for MergeAction. A typical scenario is adding menu items to the end of the menu when some part of the program is activated.";
                    ShowAppendSample();
                    break;
                case MergeSample.InsertInSameLocation:
                    ScenarioText = "This sample adds items to the middle of the list using MergeAction.Insert.\r\n\r\nNotice here how the items are added in reverse order: four, three, two, one. This is because they all have the same merge index.\r\n\r\nA typical scenario is adding menu items to the middle or beginning of the menu when some part of the program is activated. ";
                    ShowInsertInSameLocationSample();
                    break;
                case MergeSample.InsertInSameLocationPreservingOrder:
                    ScenarioText = "This sample is the same as InsertInSameLocation, except the items are added in normal order by increasing the MergeIndex of \"two merged items\" to be 3, \"three merged items\" to be 5, and so on.\r\n  You could also add the original items backwards to the source ContextMenuStrip.";
                    ShowInsertInSameLocationPreservingOrderSample();
                    break;
                case MergeSample.ReplacingItems:
                    ScenarioText = "This sample replaces a menu item using MergeAction.Replace. Use this for the MDI scenario where saving does something completely different.\r\n\r\nMatching is based on the Text property. If there is no text match, merging reverts to MergeIndex.";
                    ShowReplaceSample();
                    break;
                case MergeSample.MatchOnly:
                    ScenarioText = "This sample adds only the subitems from the child to the target ContextMenuStrip.";
                    ShowMatchOnlySample();
                    break;
            }
            // Reapply with the new settings.
            ToolStripManager.Merge(cmsItemsToMerge, cmsBase);
        }
    }
}

Private Property CurrentSample() As MergeSample
   Get
      Return currentSample1
   End Get
   Set
      If currentSample1 <> value Then
         Dim resetRequired As Boolean = False
         
         If currentSample1 = MergeSample.MatchOnly Then
            resetRequired = True
         End If
         currentSample1 = value
         ' Undo previous merge, if any.
         ToolStripManager.RevertMerge(cmsBase, cmsItemsToMerge)
         If resetRequired Then
            RebuildItemsToMerge()
         End If
         
         Select Case currentSample1
            Case MergeSample.None
                  Return
            Case MergeSample.Append
               ScenarioText = "This sample adds items to the end of the list using MergeAction.Append." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "This is the default setting for MergeAction. A typical scenario is adding menu items to the end of the menu when some part of the program is activated."
               ShowAppendSample()
            Case MergeSample.InsertInSameLocation
               ScenarioText = "This sample adds items to the middle of the list using MergeAction.Insert." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "Notice here how the items are added in reverse order: four, three, two, one. This is because they all have the same merge index." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "A typical scenario is adding menu items to the middle or beginning of the menu when some part of the program is activated. "
               ShowInsertInSameLocationSample()
            Case MergeSample.InsertInSameLocationPreservingOrder
               ScenarioText = "This sample is the same as InsertInSameLocation, except the items are added in normal order by increasing the MergeIndex of ""two merged items"" to be 3, ""three merged items"" to be 5, and so on." + ControlChars.Cr + ControlChars.Lf + "  You could also add the original items backwards to the source ContextMenuStrip."
               ShowInsertInSameLocationPreservingOrderSample()
            Case MergeSample.ReplacingItems
               ScenarioText = "This sample replaces a menu item using MergeAction.Replace. Use this for the MDI scenario where saving does something completely different." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "Matching is based on the Text property. If there is no text match, merging reverts to MergeIndex."
               ShowReplaceSample()
            Case MergeSample.MatchOnly
               ScenarioText = "This sample adds only the subitems from the child to the target ContextMenuStrip."
               ShowMatchOnlySample()
         End Select
         
         ' Reapply with the new settings.
         ToolStripManager.Merge(cmsItemsToMerge, cmsBase)
      End If
   End Set
End Property

설명

사용 된 ToolStripManager.Merge 결합 하는 방법 ToolStrip 다른 유형의 개체입니다.

사용 합니다 ToolStripManager.Merge 결합 하는 방법 ToolStrip 등의 동일한 개체 입력 ToolStrip 다른 개체 ToolStrip 개체를 MenuStrip 다른 개체 MenuStrip 개체 및 등입니다.

합니다 ToolStrip.AllowMerge 속성으로 설정 되어 있어야 true 둘 다에 대해 ToolStrip 개체 또는이 메서드에서 반환 false합니다.

참고

두 개 있는 경우 MenuStrip 설정 하는 MDI 자식 폼의 컨트롤 IsMdiContainertrue 부모 폼 병합 중 하나만 내용의 MenuStrip 컨트롤입니다. 사용 하 여 Merge 내용을 병합 하 여 추가 자식 MenuStrip MDI 부모 폼의 컨트롤입니다.

추가 정보

적용 대상