当前位置: 首页>>代码示例>>C#>>正文


C# ToolStrip.RevertMergeItem方法代码示例

本文整理汇总了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;
		}
开发者ID:Clancey,项目名称:MonoMac.Windows.Form,代码行数:49,代码来源:ToolStripManager.cs


注:本文中的System.Windows.Forms.ToolStrip.RevertMergeItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。