public void RemoveMenuItem(FrmMenuPage menuPage, FrmMenuGroup menuGroup, FrmMenuItem menuItem) { RibbonControl mainMenu = application.MainRibbon; if (MainMenuPages[menuPage.PageName] == null) { return; } if (mainMenu != null) { if (menuGroup.Tag is RibbonPageGroup) { RibbonPageGroup _mGroup = menuGroup.Tag as RibbonPageGroup; { foreach (BarItemLink _mi in _mGroup.ItemLinks) { if (_mi.Caption == menuItem.MenuTitle) { _mGroup.ItemLinks.Remove(_mi); break; } } } } else { MessageBox.Show(string.Format("菜单页{0}不存在!", menuPage.PageName)); } } }
public void AddMenuItem(FrmMenuGroup menuGroup, FrmMenuItem menuItem) { RibbonControl mainMenu = application.MainRibbon; if (mainMenu != null) { if (menuGroup.Tag is RibbonPageGroup) { RibbonPageGroup _mGroup = menuGroup.Tag as RibbonPageGroup; BarItem _menuitem = new BarButtonItem(); _menuitem.Caption = menuItem.MenuTitle; _menuitem.Tag = menuItem; _menuitem.LargeGlyph = menuItem.MenuIcon; _menuitem.Glyph = menuItem.MenuIcon; _menuitem.ItemClick += new ItemClickEventHandler(_menuitem_ItemClick); _menuitem.LargeWidth = (PicWidth == -1) ? menuItem.MenuPicWidth : PicWidth; _mGroup.ItemLinks.Add(_menuitem); } else { MessageBox.Show(string.Format("菜单组{0}不存在!", menuGroup.GroupName)); } } }
protected void _menuitem_ItemClick(object sender, ItemClickEventArgs e) { BarItem _bi = e.Item; if (_bi.Tag is FrmMenuItem) { FrmMenuItem _mi = _bi.Tag as FrmMenuItem; if (_mi.MenuCommand != null) { MenuCommandDefine _cd = _mi.MenuCommand; LastClickMenu = _mi; _cd.RunCommand(_mi.MenuID); } } }