Example #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);
            }
        }
Example #2
0
 public void OnBeforeContextMenuClick(GridControlExMenuEventArg arg)
 {
     if (_BeforeContextMenuClick != null)
     {
         _BeforeContextMenuClick(this, arg);
     }
 }
Example #3
0
        void grdCtlMain_BeforeContextMenuClick(object sender, MB.XWinLib.XtraGrid.GridControlExMenuEventArg arg)
        {
            if (arg.MenuType == MB.XWinLib.XtraGrid.XtraContextMenuType.Copy)
            {
                arg.Handled = true;

                dataCopy();
            }
            else if (arg.MenuType == MB.XWinLib.XtraGrid.XtraContextMenuType.Past)
            {
                arg.Handled = true;

                IDataObject data = Clipboard.GetDataObject();

                object ss = data.GetData(typeof(string));
                dataPast(ss.ToString());
            }
            else if (arg.MenuType == XtraContextMenuType.DataImport)
            {
                arg.Handled = true;
                dataImport();
            }
            else if (arg.MenuType == XtraContextMenuType.QuickInput)
            {
                arg.Handled = true;

                if (arg.Column != null)
                {
                    DevExpress.XtraGrid.Views.Grid.GridView gridView = gridViewMain;
                    if (arg.Column.OptionsColumn.AllowEdit && gridView.FocusedRowHandle >= 0)
                    {
                        var dre = MB.WinBase.MessageBoxEx.Question("是否决定以当前选择列的值进行快速填充");
                        if (dre != DialogResult.Yes)
                        {
                            return;
                        }

                        DataRow entity = gridView.GetDataRow(gridView.FocusedRowHandle);
                        object  val    = entity[arg.Column.FieldName];
                        if (val != null)
                        {
                            int count = gridView.RowCount;
                            for (int i = 0; i < count; i++)
                            {
                                DataRow dr = gridView.GetDataRow(i);
                                GridRowCellEditEventArgs cellarg = new GridRowCellEditEventArgs(dr, arg.Column);
                                cellarg.AllowEdit = arg.Column.OptionsColumn.AllowEdit;
                                OnRowCellEditForEditing(cellarg);
                                if (cellarg.AllowEdit)
                                {
                                    gridView.SetRowCellValue(i, arg.Column.FieldName, val);
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
0
        void _XtraGrid_BeforeContextMenuClick(object sender, MB.XWinLib.XtraGrid.GridControlExMenuEventArg arg)
        {
            if (arg.MenuType == XtraContextMenuType.QuickInput)
            {
                arg.Handled = true;

                if (arg.Column == null)
                {
                    return;
                }

                DevExpress.XtraGrid.Views.Grid.GridView gridView = _AdvBandGridView;
                if (!arg.Column.OptionsColumn.AllowEdit || gridView.FocusedRowHandle < 0)
                {
                    return;
                }

                if (gridView.SortedColumns.Contains(arg.Column))
                {
                    MB.WinBase.MessageBoxEx.Show("当前列正在排序状态,不能进行快速填充.请先取消排序");
                    return;
                }

                var dre = MB.WinBase.MessageBoxEx.Question("是否决定以当前选择列的值进行快速填充");
                if (dre != DialogResult.Yes)
                {
                    return;
                }

                DataRow entity = gridView.GetDataRow(gridView.FocusedRowHandle);
                object  val    = entity[arg.Column.FieldName];

                if (val == null)
                {
                    return;
                }

                int count = gridView.RowCount;
                for (int i = 0; i < count; i++)
                {
                    //判断当前列是否可以编辑
                    if (!checCanEdit(i, arg.Column.FieldName))
                    {
                        continue;
                    }

                    gridView.SetRowCellValue(i, arg.Column.FieldName, val);
                }
            }
        }