private void OnCustomMenuItemClose(object sender, EventArgs e) { Infragistics.Win.UltraWinTabbedMdi.MdiTab tab = null; Infragistics.Win.IGControls.IGMenuItem mi = sender as Infragistics.Win.IGControls.IGMenuItem; switch (mi.Index) { case 0: tab = mi.Tag as Infragistics.Win.UltraWinTabbedMdi.MdiTab; tab.Close(); break; case 1: do { tabManager.TabGroups[0].Tabs[0].Close(); } while (tabManager.TabGroups.Count != 0); break; case 2: tab = mi.Tag as Infragistics.Win.UltraWinTabbedMdi.MdiTab; do { if (tabManager.TabGroups[0].Tabs[0].Key != tab.Key) { tabManager.TabGroups[0].Tabs[0].Close(); } else if (tabManager.TabGroups[0].Tabs.Count > 1) { tabManager.TabGroups[0].Tabs[1].Close(); } } while (tabManager.TabGroups[0].Tabs.Count != 1); break; } }
private void tabManager_InitializeContextMenu(object sender, Infragistics.Win.UltraWinTabbedMdi.MdiTabContextMenuEventArgs e) { if (e.ContextMenuType == Infragistics.Win.UltraWinTabbedMdi.MdiTabContextMenu.Default) { e.ContextMenu.MenuItems.Clear(); var closeMenuItem = new Infragistics.Win.IGControls.IGMenuItem("关闭") { Tag = e.Tab }; closeMenuItem.Click += new EventHandler(OnCustomMenuItemClose); var closeAllMenuItem = new Infragistics.Win.IGControls.IGMenuItem("关闭所有窗体") { Tag = e.Tab }; closeAllMenuItem.Click += new EventHandler(OnCustomMenuItemClose); var closeAllExpOneMenuItem = new Infragistics.Win.IGControls.IGMenuItem("除此之外全部关闭") { Tag = e.Tab }; closeAllExpOneMenuItem.Click += new EventHandler(OnCustomMenuItemClose); e.ContextMenu.MenuItems.Add(closeMenuItem); e.ContextMenu.MenuItems.Add(closeAllMenuItem); e.ContextMenu.MenuItems.Add(closeAllExpOneMenuItem); } }
private void ultraTabbedMdiManager1_InitializeContextMenu(object sender, Infragistics.Win.UltraWinTabbedMdi.MdiTabContextMenuEventArgs e) { if (e.ContextMenuType == Infragistics.Win.UltraWinTabbedMdi.MdiTabContextMenu.Default) { e.ContextMenu.MenuItems.Clear(); Infragistics.Win.IGControls.IGMenuItem item1 = new Infragistics.Win.IGControls.IGMenuItem("关闭"); item1.Tag = e.Tab; item1.Click += new EventHandler(OnCustomMenuItemClose); e.ContextMenu.MenuItems.Add(item1); } }
private void OnCustomMenuItemClose(object sender, EventArgs e) { Infragistics.Win.IGControls.IGMenuItem mi = sender as Infragistics.Win.IGControls.IGMenuItem; Infragistics.Win.UltraWinTabbedMdi.MdiTab tab = mi.Tag as Infragistics.Win.UltraWinTabbedMdi.MdiTab; tab.Close(); }