Exemplo n.º 1
0
        private System.Windows.Forms.MenuItem createMenuByType(XtraContextMenuType menuType)
        {
            Type   enumType = typeof(XtraContextMenuType);
            string str      = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false);

            str = CLL.Convert(str);
            XtraMenu menu = new XtraMenu(str, new System.EventHandler(menuItemClick), menuType);

            _GridMenu.MenuItems.Add(menu);
            if (menuType == XtraContextMenuType.ColumnsAllowSort)
            {
                menu.Checked = true;
            }
            if (menuType == XtraContextMenuType.Chart)
            {
                var templateMenu = new WinDxChart.Chart.ChartTemplateMenu(_XtraGrid);
                System.Windows.Forms.ContextMenu contextMenu = templateMenu.ChartContextMenu;
                int count = contextMenu.MenuItems.Count;
                for (int i = 0; i < count; i++)
                {
                    menu.MenuItems.Add(contextMenu.MenuItems[0]);
                }
            }

            return(menu);
        }
Exemplo n.º 2
0
        //根据类型创建菜单项
        private ToolStripMenuItem createMenuByType(GeneralOperateMenus menuType)
        {
            Type   enumType = typeof(GeneralOperateMenus);
            string str      = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false);

            str = CLL.Convert(str);
            ToolStripMenuItem menu = new ToolStripMenuItem(str, (Image)null, new System.EventHandler(menuItemClick));

            _MenuBinding.Add(menuType, menu);

            _ContextMenuStrip.Items.Add(menu);
            return(menu);
        }