本文整理汇总了C#中System.Windows.Forms.MainMenu.MergeMenu方法的典型用法代码示例。如果您正苦于以下问题:C# MainMenu.MergeMenu方法的具体用法?C# MainMenu.MergeMenu怎么用?C# MainMenu.MergeMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MainMenu
的用法示例。
在下文中一共展示了MainMenu.MergeMenu方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMaximizedMenu
private MainMenu CreateMaximizedMenu ()
{
Form parent = (Form) mdi_container.Parent;
#if NET_2_0
if (form.MainMenuStrip != null || parent.MainMenuStrip != null)
return null;
#endif
MainMenu res = new MainMenu ();
if (parent.Menu != null) {
MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
res.MergeMenu (clone);
}
if (form.Menu != null) {
MainMenu clone = (MainMenu) form.Menu.CloneMenu ();
res.MergeMenu (clone);
}
if (res.MenuItems.Count == 0)
res.MenuItems.Add (new MenuItem ()); // Dummy item to get the menu height correct
res.MenuItems.Insert (0, icon_menu);
res.SetForm (parent);
return res;
}
示例2: MenuItemMerge
public void MenuItemMerge ()
{
MenuItem itemA2 = new MenuItem ("Exit");
itemA2.MergeType = MenuMerge.MergeItems;
itemA2.MergeOrder = 3;
MenuItem itemA1 = new MenuItem ("File");
itemA1.MenuItems.Add (itemA2);
itemA1.MergeType = MenuMerge.MergeItems;
MenuItem itemB2 = new MenuItem ("Open");
itemB2.MergeOrder = 1;
itemB2.MergeType = MenuMerge.Add;
MenuItem itemB3 = new MenuItem ("Close");
itemB3.MergeOrder = 2;
itemB3.MergeType = MenuMerge.Add;
MenuItem itemB1 = new MenuItem ("File");
itemB1.MenuItems.Add (itemB2);
itemB1.MenuItems.Add (itemB3);
itemB1.MergeType = MenuMerge.MergeItems;
MainMenu mainMenu1 = new MainMenu();
mainMenu1.MenuItems.Add (itemA1);
MainMenu mainMenu2 = new MainMenu();
mainMenu2.MenuItems.Add (itemB1);
mainMenu1.MergeMenu (mainMenu2);
Assert.AreEqual ("File", mainMenu1.MenuItems[0].Text, "ItemMerge#1");
Assert.AreEqual ("Open", mainMenu1.MenuItems[0].MenuItems[0].Text, "ItemMerge#2");
Assert.AreEqual ("Close", mainMenu1.MenuItems[0].MenuItems[1].Text, "ItemMerge#3");
Assert.AreEqual ("Exit", mainMenu1.MenuItems[0].MenuItems[2].Text, "ItemMerge#4");
}
示例3: MenuItemSimpleMerge
public void MenuItemSimpleMerge ()
{
MainMenu mymainmenu1 = new MainMenu ();
MainMenu mymainmenu2 = new MainMenu ();
MenuItem mymenuitem1 = new MenuItem ();
MenuItem mymenuitem2 = new MenuItem ();
mymenuitem1.Text = "A";
mymenuitem2.Text = "B";
mymainmenu1.MenuItems.Add (mymenuitem1);
mymainmenu2.MenuItems.Add (mymenuitem2);
mymainmenu1.MergeMenu (mymainmenu2);
Assert.AreEqual (2, mymainmenu1.MenuItems.Count, "SimpleMerge#1");
}