ToolStripManager.RevertMerge Method

Definition

Undoes a merging of two ToolStrip objects.

Overloads

RevertMerge(String)

Undoes a merging of two ToolStrip objects, returning the ToolStrip with the specified name to its state before the merge and nullifying all previous merge operations.

RevertMerge(ToolStrip)

Undoes a merging of two ToolStrip objects, returning the specified ToolStrip to its state before the merge and nullifying all previous merge operations.

RevertMerge(ToolStrip, ToolStrip)

Undoes a merging of two ToolStrip objects, returning both ToolStrip controls to their state before the merge and nullifying all previous merge operations.

RevertMerge(String)

Source:
ToolStripManager.cs
Source:
ToolStripManager.cs
Source:
ToolStripManager.cs

Undoes a merging of two ToolStrip objects, returning the ToolStrip with the specified name to its state before the merge and nullifying all previous merge operations.

C#
public static bool RevertMerge(string targetName);

Parameters

targetName
String

The name of the ToolStripItem for which to undo a merge operation.

Returns

true if the undoing of the merge is successful; otherwise, false.

Remarks

The ToolStrip.AllowMerge property must be set to true for both ToolStrip objects, or this method returns false.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

RevertMerge(ToolStrip)

Source:
ToolStripManager.cs
Source:
ToolStripManager.cs
Source:
ToolStripManager.cs

Undoes a merging of two ToolStrip objects, returning the specified ToolStrip to its state before the merge and nullifying all previous merge operations.

C#
public static bool RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip);

Parameters

targetToolStrip
ToolStrip

The ToolStripItem for which to undo a merge operation.

Returns

true if the undoing of the merge is successful; otherwise, false.

Examples

The following code example undoes the merging of menu items. This example is part of a larger example available in the ToolStripManager class overview.

C#
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);
        }
    }
}

Remarks

The ToolStrip.AllowMerge property must be set to true for both ToolStrip objects, or this method returns false.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

RevertMerge(ToolStrip, ToolStrip)

Source:
ToolStripManager.cs
Source:
ToolStripManager.cs
Source:
ToolStripManager.cs

Undoes a merging of two ToolStrip objects, returning both ToolStrip controls to their state before the merge and nullifying all previous merge operations.

C#
public static bool RevertMerge(System.Windows.Forms.ToolStrip targetToolStrip, System.Windows.Forms.ToolStrip sourceToolStrip);

Parameters

targetToolStrip
ToolStrip

The name of the ToolStripItem for which to undo a merge operation.

sourceToolStrip
ToolStrip

The ToolStrip that was merged with the targetToolStrip.

Returns

true if the undoing of the merge is successful; otherwise, false.

Exceptions

The sourceToolStrip is null.

Remarks

The ToolStrip.AllowMerge property must be set to true for both ToolStrip objects, or this method returns false.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10