本文整理汇总了C#中System.Windows.Forms.ToolStrip.RevertMergeItem方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStrip.RevertMergeItem方法的具体用法?C# ToolStrip.RevertMergeItem怎么用?C# ToolStrip.RevertMergeItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStrip
的用法示例。
在下文中一共展示了ToolStrip.RevertMergeItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RevertMerge
public static bool RevertMerge (ToolStrip targetToolStrip, ToolStrip sourceToolStrip)
{
if (sourceToolStrip == null)
throw new ArgumentNullException ("sourceToolStrip");
List<ToolStripItem> items_to_move = new List<ToolStripItem> ();
// Find every ToolStripItem who's Owner is the source toolstrip
// - If it's a TSMI, see if any of the subitems need to be moved back
foreach (ToolStripItem tsi in targetToolStrip.Items) {
if (tsi.Owner == sourceToolStrip)
items_to_move.Add (tsi);
else if (tsi is ToolStripMenuItem)
foreach (ToolStripItem menuitem in (tsi as ToolStripMenuItem).DropDownItems)
foreach (ToolStripMenuItem tsmi in sourceToolStrip.Items)
if (menuitem.Owner == tsmi.DropDown)
items_to_move.Add (menuitem);
}
// If we didn't find anything, return false
if (items_to_move.Count == 0 && targetToolStrip.HiddenMergedItems.Count == 0)
return false;
// Put back all the target's items removed in the merge
while (targetToolStrip.HiddenMergedItems.Count > 0) {
targetToolStrip.RevertMergeItem (targetToolStrip.HiddenMergedItems[0]);
targetToolStrip.HiddenMergedItems.RemoveAt (0);
}
sourceToolStrip.SuspendLayout ();
targetToolStrip.SuspendLayout ();
// Revert everything
while (items_to_move.Count > 0) {
sourceToolStrip.RevertMergeItem (items_to_move[0]);
items_to_move.Remove (items_to_move[0]);
}
sourceToolStrip.ResumeLayout ();
targetToolStrip.ResumeLayout ();
sourceToolStrip.IsCurrentlyMerged = false;
targetToolStrip.IsCurrentlyMerged = false;
sourceToolStrip.CurrentlyMergedWith = null;
targetToolStrip.CurrentlyMergedWith = null;
return true;
}