/// <summary> /// 创建可编辑的XtraGrid 控件。 /// </summary> /// <param name="bindParam"></param> /// <param name="configXmlFile"></param> /// <returns></returns> public bool CreateEditXtraGrid(GridDataBindingParam bindParam, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo) { string viewTypeName = bindParam.XtraGrid.MainView.GetType().Name; if (viewTypeName == "GridView") { editViewGrid(bindParam, colPropertys, editCols, gridViewLayoutInfo); } else if (viewTypeName == "AdvBandedGridView" || viewTypeName == "BandedGridView") { if (gridViewLayoutInfo == null) { throw new MB.Util.APPException("创建 AdvBandedGridView 网格视图必须在相应的 XML 文件中配置 GridViewLayoutInfo"); } CreateEditBandXtraGrid(bindParam, colPropertys, editCols, gridViewLayoutInfo); } else { throw new MB.Util.APPException("目前编辑的XtrGrid 只支持AdvBandedGridView 和 GridView的格式。请检查你设置的XtrGrid View是否为这种类型。"); } return(true); }
void DefaultDataImportDialog_Load(object sender, EventArgs e) { MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo = MB.WinBase.LayoutXmlConfigHelper.Instance.GetGridColumnLayoutInfo(_XmlFileName, string.Empty); var detailBindingParams = new MB.XWinLib.GridDataBindingParam(grdCtlMain, _CurrentImportData, false); MB.XWinLib.XtraGrid.XtraGridEditHelper.Instance.CreateEditXtraGrid(detailBindingParams, _ColPropertys, _EditCols, gridViewLayoutInfo); // MB.XWinLib.XtraGrid.XtraGridHelper.Instance.BindingToXtraGrid(grdCtlMain, _CurrentImportData, _ColPropertys, _EditCols, _XmlFileName, true); displayMessage(); grdCtlMain.ReSetContextMenu(MB.XWinLib.XtraGrid.XtraContextMenuType.SaveGridState | MB.XWinLib.XtraGrid.XtraContextMenuType.Delete); grdCtlMain.BeforeContextMenuClick += new XWinLib.XtraGrid.GridControlExMenuEventHandle(grdCtlMain_BeforeContextMenuClick); DevExpress.XtraGrid.Views.Grid.GridView view = grdCtlMain.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.RowStyle += new RowStyleEventHandler(view_RowStyle); } }
/// <summary> /// 通过XML布局的配置信息创建布局列. /// </summary> /// <param name="bandGridView"></param> /// <param name="gridBand"></param> /// <param name="colPropertys"></param> /// <param name="editCols"></param> /// <param name="gridViewLayoutInfo"></param> /// <param name="columnLayoutInfo"></param> public void CreateBandedGridViewColumns(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView bandGridView, DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo, MB.WinBase.Common.GridColumnLayoutInfo columnLayoutInfo) { if (string.Compare(columnLayoutInfo.Type, XtraGridViewHelper.BAND_TYPE_NAME, true) == 0) { createGridBand(bandGridView, gridBand, colPropertys, editCols, gridViewLayoutInfo, columnLayoutInfo); } else { DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bColumn = new DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn(); if (!colPropertys.ContainsKey(columnLayoutInfo.ColumnXmlCfgName)) { return; } createBandColumn(bandGridView, gridBand, colPropertys, editCols, gridViewLayoutInfo, columnLayoutInfo, bColumn); } }
/// <summary> /// 根据配置的XML文件设置列的信息。 /// </summary> /// <param name="pColumn"></param> /// <param name="pFieldInfo"></param> public void SetEditColumn(DevExpress.XtraGrid.Columns.GridColumn gridColumn, MB.WinBase.Common.ColumnPropertyInfo columnPropertyInfo, MB.WinBase.Common.GridColumnLayoutInfo columnLayoutInfo, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo) { gridColumn.Caption = columnPropertyInfo.Description; if (columnLayoutInfo != null) { gridColumn.FieldName = columnLayoutInfo.Name; } else { gridColumn.FieldName = columnPropertyInfo.Name; } gridColumn.Name = "XtCol" + columnPropertyInfo.Name; gridColumn.Width = columnPropertyInfo.VisibleWidth; if (columnPropertyInfo.Visibled && columnPropertyInfo.VisibleWidth > 0) { gridColumn.VisibleIndex = columnPropertyInfo.OrderIndex; } else { gridColumn.VisibleIndex = -1; } if (columnPropertyInfo.DataType == "Systen.Byte[]") //目前先假设System.Byte[] 类型都是 System.Image { } else { gridColumn.OptionsColumn.AllowSort = columnPropertyInfo.CanSort ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False; gridColumn.OptionsColumn.AllowGroup = columnPropertyInfo.CanGroup ? DevExpress.Utils.DefaultBoolean.True : DevExpress.Utils.DefaultBoolean.False; } if (gridViewLayoutInfo != null && gridViewLayoutInfo.ReadOnly) { XtraGridViewHelper.Instance.SetColumn(gridColumn, columnPropertyInfo, columnLayoutInfo.Name); } else { gridColumn.OptionsColumn.ReadOnly = !columnPropertyInfo.CanEdit; if (columnPropertyInfo.CanEdit) { if (columnPropertyInfo.IsKey) { gridColumn.AppearanceHeader.Font = new Font(gridColumn.AppearanceHeader.Font, System.Drawing.FontStyle.Bold); gridColumn.AppearanceHeader.ForeColor = Color.Red; //不可重复项目为红色而且是粗体。 } else if (!columnPropertyInfo.IsNull) { gridColumn.AppearanceHeader.ForeColor = Color.Red; //红色为必填项 } else { gridColumn.AppearanceHeader.ForeColor = Color.Blue; //蓝色为可编辑项 } } else { //gridColumn.OptionsColumn.AllowFocus = true; gridColumn.OptionsColumn.AllowEdit = false; gridColumn.AppearanceCell.Font = new Font(gridColumn.AppearanceCell.Font, System.Drawing.FontStyle.Bold); gridColumn.AppearanceCell.BackColor = Color.WhiteSmoke; } } if (columnLayoutInfo != null) { XtraGridViewHelper.Instance.SetColumnDisplayFormat(gridColumn, columnPropertyInfo, columnLayoutInfo); } }
//创建BandColumn private void createBandColumn(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView bandGridView, DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo, MB.WinBase.Common.GridColumnLayoutInfo columnLayoutInfo, DevExpress.XtraGrid.Views.BandedGrid.BandedGridColumn bColumn) { MB.WinBase.Common.ColumnPropertyInfo fInfo = colPropertys[columnLayoutInfo.ColumnXmlCfgName]; //判断该列是否可以进行编辑 DevExpress.XtraEditors.Repository.RepositoryItem rEdit = null; if (editCols != null && editCols.ContainsKey(columnLayoutInfo.ColumnXmlCfgName)) { rEdit = CreateEditItemByEditInfo(editCols[columnLayoutInfo.ColumnXmlCfgName], fInfo.CanEdit, fInfo.DataType);//根据用户XML配置的信息获取一个编辑的列。 } else { rEdit = CreateEditItemByCol(fInfo, false); } rEdit.Name = fInfo.Name; bColumn.ColumnEdit = rEdit; bColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; // bColumn.DisplayFormat = new DevExpress.Utils.FormatInfo bandGridView.GridControl.RepositoryItems.Add(rEdit); //这句代码必须添加上,否则顺序的调整将会出现问题。 bandGridView.Columns.Add(bColumn); if (gridBand != null) { gridBand.Columns.Add(bColumn); } SetEditColumn(bColumn, fInfo, columnLayoutInfo, gridViewLayoutInfo); }
//创建网格的GridBand。 private void createGridBand(DevExpress.XtraGrid.Views.BandedGrid.BandedGridView bandGridView, DevExpress.XtraGrid.Views.BandedGrid.GridBand gridBand, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo, MB.WinBase.Common.GridColumnLayoutInfo columnLayoutInfo) { DevExpress.XtraGrid.Views.BandedGrid.GridBand bdc = new DevExpress.XtraGrid.Views.BandedGrid.GridBand(); if (!string.IsNullOrEmpty(columnLayoutInfo.Name)) { bdc.Name = columnLayoutInfo.Name; } if (gridBand == null) { bandGridView.Bands.Add(bdc); } else { gridBand.Children.Add(bdc); } bdc.Width = columnLayoutInfo.VisibleWidth; bdc.Caption = columnLayoutInfo.Text; bdc.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; // bdc.Index = columnLayoutInfo.Index; //背景颜色处理 if (!string.IsNullOrEmpty(columnLayoutInfo.BackColor)) { Color bc = MB.Util.MyConvert.Instance.ToColor(columnLayoutInfo.BackColor); if (bc != Color.Empty) { bdc.AppearanceHeader.BackColor2 = bc; } } //字体颜色 if (!string.IsNullOrEmpty(columnLayoutInfo.ForeColor)) { Color fc = MB.Util.MyConvert.Instance.ToColor(columnLayoutInfo.ForeColor); if (fc != Color.Empty) { bdc.AppearanceHeader.ForeColor = fc; } } //字体颜色 if (columnLayoutInfo.ForeFontSize > 1) { bdc.AppearanceHeader.Font = new Font(bdc.AppearanceHeader.Font.FontFamily, columnLayoutInfo.ForeFontSize); } if (columnLayoutInfo.Childs != null && columnLayoutInfo.Childs.Count > 0) { { foreach (var childLayoutInfo in columnLayoutInfo.Childs) { CreateBandedGridViewColumns(bandGridView, bdc, colPropertys, editCols, gridViewLayoutInfo, childLayoutInfo); } } } if (columnLayoutInfo.Fixed != MB.WinBase.Common.FixedStyle.None) { if (columnLayoutInfo.Fixed == MB.WinBase.Common.FixedStyle.Left) { bdc.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left; } else { bdc.Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Right; } } }
/// <summary> /// 创建 BandXtraGrid 网格编辑或者浏览数据。 /// </summary> /// <param name="bindParam"></param> /// <param name="colPropertys"></param> /// <param name="editCols"></param> /// <returns></returns> public bool CreateEditBandXtraGrid(GridDataBindingParam bindParam, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo) { DevExpress.XtraGrid.GridControl xtraGCtl = bindParam.XtraGrid; // object dataSource = bindParam.DataSource; DevExpress.XtraGrid.Views.BandedGrid.BandedGridView bandGridView = xtraGCtl.MainView as DevExpress.XtraGrid.Views.BandedGrid.BandedGridView; if (bandGridView == null) { throw new MB.Util.APPException("目前编辑的XtrGrid 只支持AdvBandedGridView的格式。请检查你设置的XtrGrid View是否为这种类型。"); } if (colPropertys == null || colPropertys.Count == 0) { throw new MB.Util.APPException("ColumnPropertyInfo 的信息 不能为空。"); } // 设置控件的显示样式 //viewStye.SetStyles(xtraGCtl); XtraGridViewHelper.Instance.SetGridView(bandGridView, colPropertys); if (bandGridView.Columns.Count > 0) { bandGridView.Columns.Clear(); } foreach (DevExpress.XtraGrid.Views.BandedGrid.GridBand band in bandGridView.Bands) { band.Columns.Clear(); } bandGridView.Bands.Clear(); if (gridViewLayoutInfo == null) { throw new MB.Util.APPException("在绑定多维表头时,可以没有在对应的XML 文件中配置 对应 GridViews/GridViewLayout", MB.Util.APPMessageType.SysErrInfo); } //根据业务处理对象得到对应的 UI 编辑设置信息。 foreach (var columnLayoutInfo in gridViewLayoutInfo.GridLayoutColumns) { CreateBandedGridViewColumns(bandGridView, null, colPropertys, editCols, gridViewLayoutInfo, columnLayoutInfo); } //不管什么时候都恢复保存的状态 XtraGridViewHelper.Instance.RestoreXtraGridState(bindParam.XtraGrid); bool isReadonly = gridViewLayoutInfo == null && gridViewLayoutInfo.ReadOnly; XtraContextMenuType viewPopuMenus = isReadonly ? XtraContextMenuType.SaveGridState | XtraContextMenuType.Export | XtraContextMenuType.Chart : XtraContextMenuType.SaveGridState | XtraContextMenuType.Export | XtraContextMenuType.DataImport | XtraContextMenuType.ColumnsAllowSort | XtraContextMenuType.BatchAdd | XtraContextMenuType.QuickInput; XtraGridViewHelper.Instance.SetGridViewNewItem(xtraGCtl, true, viewPopuMenus); if (isReadonly) { bandGridView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None; } if (colPropertys != null) { XtraGridViewHelper.Instance.SetGroupSummary(bandGridView, colPropertys); } xtraGCtl.DataSource = MB.Util.MyConvert.Instance.ToGridViewSource(bindParam.DataSource); return(true); }
//编辑一般ViewGrid 格式 private bool editViewGrid(GridDataBindingParam bindParam, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> objPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo) { if (gridViewLayoutInfo != null) { MB.Util.TraceEx.Write("OK"); } DevExpress.XtraGrid.GridControl xtraGCtl = bindParam.XtraGrid; MB.XWinLib.XtraGrid.XtraGridViewHelper.Instance.SetEditGridAutoInfo(xtraGCtl); XtraGridViewHelper.Instance.SetXtraGridSkin(xtraGCtl, XtraGridSkin.Edit); DevExpress.XtraGrid.Views.Grid.GridView gridView = xtraGCtl.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (gridView == null) { throw new MB.Util.APPException("目前编辑的XtrGrid 只支持DevExpress.XtraGrid.Views.Grid.GridView的格式。请检查你设置的XtrGrid View是否为这种类型。"); } if (objPropertys == null || objPropertys.Count == 0) { throw new MB.Util.APPException("业务对象没有配置对应的XML文件Columns 信息。"); } // 设置控件的显示样式 XtraGridViewHelper.Instance.SetGridView(gridView, objPropertys); if (gridView.Columns.Count > 0) { gridView.Columns.Clear(); xtraGCtl.RepositoryItems.Clear(); } //根据业务处理对象得到对应的 UI 编辑设置信息。 int i = 0; foreach (MB.WinBase.Common.ColumnPropertyInfo fInfo in objPropertys.Values) { if (!fInfo.Visibled) { continue; } DevExpress.XtraGrid.Columns.GridColumn bdc = new DevExpress.XtraGrid.Columns.GridColumn(); //判断该列是否可以进行编辑 DevExpress.XtraEditors.Repository.RepositoryItem rEdit = null; if (editCols != null && editCols.ContainsKey(fInfo.Name)) { rEdit = CreateEditItemByEditInfo(editCols[fInfo.Name], fInfo.CanEdit, fInfo.DataType);//根据用户XML配置的信息获取一个编辑的列。 } else { rEdit = CreateEditItemByCol(fInfo, false); } rEdit.Name = fInfo.Name; bdc.ColumnEdit = rEdit; xtraGCtl.RepositoryItems.Add(rEdit); gridView.Columns.Add(bdc); GridColumnLayoutInfo layoutInfo = null; if (gridViewLayoutInfo != null && gridViewLayoutInfo.GridLayoutColumns.Count > 0) { layoutInfo = gridViewLayoutInfo.GridLayoutColumns.FirstOrDefault <MB.WinBase.Common.GridColumnLayoutInfo>(o => o.Name == fInfo.Name); } SetEditColumn(bdc, fInfo, layoutInfo, gridViewLayoutInfo); i++; } //不管什么时候都恢复保存的状态 XtraGridViewHelper.Instance.RestoreXtraGridState(bindParam.XtraGrid); if (objPropertys != null) { XtraGridViewHelper.Instance.SetGroupSummary(gridView, objPropertys); } xtraGCtl.DataSource = MB.Util.MyConvert.Instance.ToGridViewSource(bindParam.DataSource); setAllowFocusColumn(gridView); XtraContextMenuType viewPopuMenus = XtraContextMenuType.SaveGridState | XtraContextMenuType.Export | XtraContextMenuType.Delete | XtraContextMenuType.DataImport | XtraContextMenuType.ColumnsAllowSort | XtraContextMenuType.BatchAdd | XtraContextMenuType.QuickInput | XtraContextMenuType.ExcelEdit; //bool autoNewItem = gridViewLayoutInfo == null || !gridViewLayoutInfo.ReadOnly; XtraGridViewHelper.Instance.SetGridViewNewItem(xtraGCtl, true, viewPopuMenus); return(true); }
protected override void LoadObjectData(MB.Util.Model.QueryParameterInfo[] queryParams) { if (_ClientRuleObject == null) { throw new MB.Util.APPException("在加载浏览窗口<DefaultViewForm>时 需要配置对应的ClientRule 类!"); } if (_ClientRuleObject.ClientLayoutAttribute == null) { throw new MB.Util.APPException(string.Format("对于客户段逻辑类 {0} ,需要配置 RuleClientLayoutAttribute.", _ClientRuleObject.GetType().FullName)); } try { //添加右键菜单扩展 if (_ClientRuleObject.ReSetContextMenu != null) { grdCtlMain.ContextMenu = _ClientRuleObject.ReSetContextMenu; //else { // grdCtlMain.ContextMenu.MenuItems.Add(new MenuItem("-")); // foreach (MenuItem item in _ClientRuleObject.ReSetContextMenu.MenuItems) { // grdCtlMain.ContextMenu.MenuItems.Add(item); // } //} } string messageHeaderKey = string.Empty; if (_ClientRuleObject.ClientLayoutAttribute.LoadType == ClientDataLoadType.ReLoad) { messageHeaderKey = _ClientRuleObject.ClientLayoutAttribute.MessageHeaderKey; } gridViewMain.RowHeight = MB.WinBase.LayoutXmlConfigHelper.Instance.GetMainGridViewRowHeight(_ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile); using (MB.WinBase.WaitCursor cursor = new MB.WinBase.WaitCursor(this)) { using (MethodTraceWithTime timeTrack = new MethodTraceWithTime(null)) { //特殊说明 2009-02-20 在这里需要增加 RefreshLookupDataSource 以便在加载数据ID 时能得到对应的描述信息。 if (_ClientRuleObject.ClientLayoutAttribute.CommunicationDataType == CommunicationDataType.DataSet) { throw new MB.Util.APPException("当前不支持基于DataSet 的网格编辑", MB.Util.APPMessageType.SysErrInfo); } else { IList lstDatas = null; try { using (QueryBehaviorScope scope = new QueryBehaviorScope(_ClientRuleObject.CurrentQueryBehavior, messageHeaderKey)) { lstDatas = _ClientRuleObject.GetObjects((int)_ClientRuleObject.MainDataTypeInDoc, queryParams); } } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, " 在加载编辑网格窗口获取数据时执行业务类的 GetObjects 出错"); } //IGridViewEditRule gridViewEditRule = _ClientRuleObject as IGridViewEditRule; //if (gridViewEditRule == null) // throw new MB.Util.APPException("所有基于Mid 子窗口网格编辑的业务类必须实现IGridViewEditRule 接口", MB.Util.APPMessageType.SysErrInfo); if (_BindingSource == null) { IBindingList bl = _ClientRuleObject.CreateMainBindList(lstDatas); _BindingSource = new MB.WinBase.Binding.BindingSourceEx(); _BindingSource.ListChanged += new ListChangedEventHandler(_BindingSource_ListChanged); _BindingSource.AddingNew += new AddingNewEventHandler(_BindingSource_AddingNew); _BindingSource.DataSource = bl; MB.WinBase.Common.GridViewLayoutInfo gridViewLayoutInfo = MB.WinBase.LayoutXmlConfigHelper.Instance.GetGridColumnLayoutInfo(_ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile, string.Empty); var detailBindingParams = new MB.XWinLib.GridDataBindingParam(grdCtlMain, _BindingSource, false); MB.XWinLib.XtraGrid.XtraGridEditHelper.Instance.CreateEditXtraGrid(detailBindingParams, _ClientRuleObject.UIRuleXmlConfigInfo.GetDefaultColumns(), _ClientRuleObject.UIRuleXmlConfigInfo.ColumnsCfgEdit, gridViewLayoutInfo); } else { MB.XWinLib.XtraGrid.XtraGridHelper.Instance.RefreshDataGrid(grdCtlMain, lstDatas); } #region 刷新status strip int rowCount = (lstDatas == null ? 0 : lstDatas.Count); var msg = string.Format("查询花费:{0} 毫秒,返回 {1} 记录,查询时间:{2}", timeTrack.GetExecutedTimes(), rowCount, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string totalPageandCurrentPage = GetTotalPageAndCurrentpage(rowCount); //刷新查询消息 labTitleMsg.Text = msg; //刷新上一页/下一页 lnkNextPage.Enabled = rowCount >= _ClientRuleObject.CurrentQueryBehavior.PageSize; lnkPreviousPage.Enabled = _ClientRuleObject.CurrentQueryBehavior.PageIndex > 0; //刷新总页数 labTotalPageNumber.Visible = IsTotalPageDisplayed; labCurrentPageNumber.Visible = IsTotalPageDisplayed; if (this.IsTotalPageDisplayed) { string[] totalPage_currentPage = totalPageandCurrentPage.Split(','); labTotalPageNumber.Text = string.Format("共{0}页", totalPage_currentPage[0]); labCurrentPageNumber.Text = string.Format("第{0}页", totalPage_currentPage[1]); } #endregion _ClientRuleObject.BindingSource = _BindingSource; } panTitle.Visible = false; } } //在GRIDVIEW创建完成以后 //根据UI RULE来判断GRID的编辑状态,是否允许新增,修改,删除 DevExpress.XtraGrid.Views.Grid.GridView mainView = grdCtlMain.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (_ClientRuleObject != null) { var rejectCfg = MB.WinBase.Atts.AttributeConfigHelper.Instance.GetModuleRejectCommands(_ClientRuleObject.GetType()); if (rejectCfg != null) { if ((rejectCfg.RejectCommands & UICommandType.AddNew) != 0) { mainView.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False; mainView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None; } else { mainView.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.True; mainView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom; } if ((rejectCfg.RejectCommands & UICommandType.Edit) != 0) { mainView.OptionsBehavior.ReadOnly = true; mainView.OptionsBehavior.Editable = false; } else { mainView.OptionsBehavior.ReadOnly = false; mainView.OptionsBehavior.Editable = true; } if ((rejectCfg.RejectCommands & UICommandType.Delete) != 0) { mainView.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False; } else { mainView.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.True; } } } } catch (MB.Util.APPException aex) { throw aex; } catch (Exception ex) { throw MB.Util.APPExceptionHandlerHelper.PromoteException(ex, "加载网格浏览编辑窗口Form_Load 时出错"); } }