示例#1
0
        private void menuItemClick(object sender, System.EventArgs e)
        {
            try {
                XtraMenu menu = sender as XtraMenu;
                if (menu == null)
                {
                    return;
                }
                DevExpress.XtraGrid.Views.Grid.GridView gridView = _XtraGrid.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView;
                GridControlExMenuEventArg arg = new GridControlExMenuEventArg(menu.MenuType);
                arg.Column = gridView.FocusedColumn;
                _XtraGrid.OnBeforeContextMenuClick(arg);

                if (!arg.Handled)
                {
                    if (menu.MenuType == XtraContextMenuType.ColumnsAllowSort)
                    {
                        clickColumnSort(menu);
                    }
                    else
                    {
                        XtraGridHelper.Instance.HandleClickXtraContextMenu(_ContainerForm, _XtraGrid, menu.MenuType);
                    }
                }
            }
            catch (Exception ex) {
                MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
            }
        }
示例#2
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);
        }
示例#3
0
 private void clickColumnSort(XtraMenu menu)
 {
     menu.Checked = !menu.Checked;
     DevExpress.XtraGrid.Views.Grid.GridView gridView = _XtraGrid.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView;
     foreach (DevExpress.XtraGrid.Columns.GridColumn col in gridView.Columns)
     {
         DevExpress.Utils.DefaultBoolean sort = menu.Checked?DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False;
         col.OptionsColumn.AllowSort = sort;
     }
 }