Пример #1
0
        private ToolStripMenuItemBase GetRootMenuItem(ToolStripMenuItemBase menuItem)
        {
            ToolStripMenuItemBase toolStripMenuItemBase = menuItem;

            while (null != toolStripMenuItemBase.OwnerItem)
            {
                toolStripMenuItemBase = (ToolStripMenuItemBase)toolStripMenuItemBase.OwnerItem;
            }
            return(toolStripMenuItemBase);
        }
Пример #2
0
        private void CloseMenuStrip(ToolStripMenuItemBase menuItem)
        {
            ToolStripDropDown dropDown = menuItem.DropDown;

            if (menuItem.Owner is MenuStrip)
            {
                menuItem.HideDropDown();
            }
            else
            {
                ((ToolStripDropDownMenu)menuItem.Owner).Close();
            }
        }