/// <summary> /// 设置grid的编辑方式。 /// </summary> /// <param name="xtraGrid"></param> /// <param name="autoNewRow"></param> public void SetGridViewNewItem(DevExpress.XtraGrid.GridControl xtraGrid, bool autoNewRow) { XtraContextMenuType viewPopuMenus = XtraContextMenuType.SaveGridState | XtraContextMenuType.Export | XtraContextMenuType.ColumnsAllowSort; if (autoNewRow) viewPopuMenus = viewPopuMenus | XtraContextMenuType.BatchAdd; SetGridViewNewItem(xtraGrid, autoNewRow, viewPopuMenus); }
/// <summary> /// 执行PivotGrid 自定义事件。 /// </summary> /// <param name="containerForm"></param> /// <param name="xtraGrid"></param> /// <param name="menuType"></param> public void HandleClickXtraContextMenu(MB.WinBase.IFace.IForm containerForm, PivotGridEx xtraGrid, XtraContextMenuType menuType) { if (containerForm == null) { return; } switch (menuType) { case XtraContextMenuType.Sort: break; case XtraContextMenuType.Style: break; case XtraContextMenuType.SaveDefaultStyle: showFrmGridLayoutManager(containerForm, xtraGrid); //modify by aifang 2012-6-7 //SavePivotGridLayout(containerForm, xtraGrid); //xtraGrid.ShowPrintPreview(); break; default: break; } }
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); }
/// <summary> /// 重新设置弹出窗口的菜单项。 /// </summary> /// <param name="createMenus"></param> public virtual void ReSetContextMenu(XtraContextMenuType createMenus) { XtraContextMenu xMenu = new XtraContextMenu(this, createMenus); base.ContextMenu = xMenu.GridContextMenu; createOptionsMenu(ContextMenu); createCopyCellMenu(ContextMenu); }
/// <summary> /// TreeList 控件Context菜单。 /// </summary> /// <param name="xtraGrid"></param> /// <param name="menuTypes"></param> public TreeListContextMenu(TreeListEx treList, XtraContextMenuType menuTypes) { _TreList = treList; _GridMenu = new System.Windows.Forms.ContextMenu(); CreateMenuItems(menuTypes); }
/// <summary> /// /// </summary> /// <param name="xtraGrid"></param> /// <param name="menuTypes"></param> public XtraContextMenu(GridControlEx xtraGrid, XtraContextMenuType menuTypes) { _XtraGrid = xtraGrid; _GridMenu = new System.Windows.Forms.ContextMenu(); if (xtraGrid.ParentForm != null) { _ContainerForm = xtraGrid.ParentForm as MB.WinBase.IFace.IForm; } CreateMenuItems(menuTypes); }
private System.Windows.Forms.MenuItem createMenuByType(XtraContextMenuType menuType) { Type enumType = typeof(XtraContextMenuType); string str = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false); str = MB.BaseFrame.CLL.Convert(str); XtraMenu menu = new XtraMenu(str, new System.EventHandler(menuItemClick), menuType); _GridMenu.MenuItems.Add(menu); if (menuType == XtraContextMenuType.ColumnsAllowSort) { menu.Checked = true; } return(menu); }
private System.Windows.Forms.MenuItem createMenuByType(XtraContextMenuType menuType) { Type enumType = typeof(XtraContextMenuType); string str = MB.Util.MyCustomAttributeLib.Instance.GetFieldDesc(enumType, menuType.ToString(), false); XtraPivotMenu menu = null; if (menuType != XtraContextMenuType.Sort) { menu = new XtraPivotMenu(str, new System.EventHandler(menuItemClick), menuType); } else { menu = new XtraPivotMenu(str, XtraContextMenuType.Sort); } this.ContextMenu.MenuItems.Add(menu); return(menu); }
/// <summary> /// 创建XtarGrid 的Context Menu 菜单项。 /// </summary> private void createMenuItems(XtraContextMenuType menuTypes) { System.Windows.Forms.ContextMenu cMenu = new ContextMenu(); this.ContextMenu = cMenu; if ((menuTypes & XtraContextMenuType.Sort) != 0) { createMenuByType(XtraContextMenuType.Sort); createSummarySortItem(); } if ((menuTypes & XtraContextMenuType.SaveDefaultStyle) != 0) { if (cMenu.MenuItems.Count > 0) { cMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.SaveDefaultStyle); } }
/// <summary> /// 创建XtarGrid 的Context Menu 菜单项。 /// </summary> public virtual void CreateMenuItems(XtraContextMenuType menuTypes) { //if(_ContainerForm==null) // return; if ((menuTypes & XtraContextMenuType.Add) != 0) { createMenuByType(XtraContextMenuType.Add); } if ((menuTypes & XtraContextMenuType.BatchAdd) != 0) { createMenuByType(XtraContextMenuType.BatchAdd); } if ((menuTypes & XtraContextMenuType.Delete) != 0) { createMenuByType(XtraContextMenuType.Delete); } if ((menuTypes & XtraContextMenuType.QuickInput) != 0) { createMenuByType(XtraContextMenuType.QuickInput); } if ((menuTypes & XtraContextMenuType.Copy) != 0) { createMenuByType(XtraContextMenuType.Copy); } if ((menuTypes & XtraContextMenuType.Past) != 0) { createMenuByType(XtraContextMenuType.Past); } if ((menuTypes & XtraContextMenuType.Aggregation) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.Aggregation); } if ((menuTypes & XtraContextMenuType.Chart) != 0) { createMenuByType(XtraContextMenuType.Chart); } if ((menuTypes & XtraContextMenuType.ViewControl) != 0) { createMenuByType(XtraContextMenuType.ViewControl); } if ((menuTypes & XtraContextMenuType.Print) != 0) { createMenuByType(XtraContextMenuType.Print); } if ((menuTypes & XtraContextMenuType.Export) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.Export); } if ((menuTypes & XtraContextMenuType.ExportAsTemplet) != 0) { createMenuByType(XtraContextMenuType.ExportAsTemplet); } if ((menuTypes & XtraContextMenuType.DataImport) != 0) { createMenuByType(XtraContextMenuType.DataImport); } if ((menuTypes & XtraContextMenuType.SaveGridState) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.SaveGridState); } if ((menuTypes & XtraContextMenuType.ColumnsAllowSort) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.ColumnsAllowSort); } if ((menuTypes & XtraContextMenuType.SortChildNode) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.SortChildNode); } }
/// <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); }
/// <summary> /// 操作当用户点击XtraGrid ContextMenu 时处理的事项。 /// </summary> /// <param name="containerForm"></param> /// <param name="xtraGrid"></param> /// <param name="menuType"></param> public void HandleClickXtraContextMenu(MB.WinBase.IFace.IForm containerForm, DevExpress.XtraGrid.GridControl xtraGrid, XtraContextMenuType menuType) { //if(containerForm==null) // return; switch (menuType) { case XtraContextMenuType.Add: case XtraContextMenuType.Print: case XtraContextMenuType.Aggregation: MB.WinBase.MessageBoxEx.Show("目前暂时先不提供右键操作的功能,请直接从工具栏上进行选择"); break; case XtraContextMenuType.Delete: //每个网格的数据 删除涉及到具体的操作,需要手工进行处理。 // MB.XWinLib.XtraGrid.XtraGridEditHelper.Instance.DeleteFocusedRow(xtraGrid); break; case XtraContextMenuType.Export: ExportToExcelAndShow(xtraGrid); break; case XtraContextMenuType.Copy: dataCopy(xtraGrid.DefaultView as DevExpress.XtraGrid.Views.Grid.GridView); break; case XtraContextMenuType.SaveGridState: showFrmGridLayoutManager(xtraGrid); break; case XtraContextMenuType.ViewControl: case XtraContextMenuType.ExportAsTemplet: case XtraContextMenuType.Past: case XtraContextMenuType.DataImport: case XtraContextMenuType.ExcelEdit: default: MB.WinBase.MessageBoxEx.Show("该菜单项对于当前对象操作无效,有可能是该对象不能进行该菜单项操作或者开发人员还没有实现该菜单项"); break; } }
/// <summary> /// 重新设置弹出窗口的菜单项。 /// </summary> /// <param name="createMenus"></param> public virtual void ReSetContextMenu(XtraContextMenuType createMenus) { createMenuItems(createMenus); }
public XtraPivotMenu(string text, System.EventHandler click, XtraContextMenuType menuType, DevExpress.XtraPivotGrid.PivotGridField sortField) : base(text, click) { _MenuType = menuType; _SortField = sortField; }
public XtraPivotMenu(string text, System.EventHandler click, XtraContextMenuType menuType) : base(text, click) { _MenuType = menuType; }
/// <summary> /// 设置grid的编辑方式。 /// </summary> /// <param name="xtraGrid"></param> /// <param name="autoNewRow"></param> public void SetGridViewNewItem(DevExpress.XtraGrid.GridControl xtraGrid, bool autoNewRow, XtraContextMenuType appendMenus) { DevExpress.XtraGrid.Views.Grid.GridView gridView = xtraGrid.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (gridView == null) return; gridView.OptionsView.NewItemRowPosition = autoNewRow ? DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom : DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.None; gridView.OptionsNavigation.AutoFocusNewRow = autoNewRow; gridView.OptionsNavigation.AutoMoveRowFocus = true; gridView.OptionsNavigation.EnterMoveNextColumn = true; //重新设置弹出菜单的操作项。 GridControlEx grdEx = xtraGrid as GridControlEx; if (grdEx != null) { grdEx.ReSetContextMenu(appendMenus); } }
public GridControlExMenuEventArg(XtraContextMenuType menuType) { _MenuType = menuType; }
public TreeListExMenuEventArg(XtraContextMenuType menuType) { _MenuType = menuType; }
/// <summary> /// 重新设置弹出窗口的菜单项。 /// </summary> /// <param name="createMenus"></param> public virtual void ReSetContextMenu(XtraContextMenuType createMenus) { TreeListContextMenu xMenu = new TreeListContextMenu(this, createMenus); base.ContextMenu = xMenu.GridContextMenu; }
/// <summary> /// 创建XtarGrid 的Context Menu 菜单项。 /// </summary> public virtual void CreateMenuItems(XtraContextMenuType menuTypes) { //if(_ContainerForm==null) // return; if ((menuTypes & XtraContextMenuType.Add) != 0) { createMenuByType(XtraContextMenuType.Add); } if ((menuTypes & XtraContextMenuType.BatchAdd) != 0) { createMenuByType(XtraContextMenuType.BatchAdd); } if ((menuTypes & XtraContextMenuType.Delete) != 0) { createMenuByType(XtraContextMenuType.Delete); } if ((menuTypes & XtraContextMenuType.QuickInput) != 0) { createMenuByType(XtraContextMenuType.QuickInput); } if ((menuTypes & XtraContextMenuType.Copy) != 0) { createMenuByType(XtraContextMenuType.Copy); } if ((menuTypes & XtraContextMenuType.Past) != 0) { createMenuByType(XtraContextMenuType.Past); } if ((menuTypes & XtraContextMenuType.Aggregation) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.Aggregation); } //WangHui:图表分析注释 if ((menuTypes & XtraContextMenuType.Chart) != 0) { if (_ContainerForm != null && _ContainerForm.ClientRuleObject != null && _ContainerForm.ClientRuleObject.UIRuleXmlConfigInfo != null) { var cfgs = _ContainerForm.ClientRuleObject.UIRuleXmlConfigInfo.GetDefaultChartViewCfg(); if (cfgs != null && cfgs.Count > 0) { createMenuByType(XtraContextMenuType.Chart); } } } ////添加图表设计 //if ((menuTypes & XtraContextMenuType.ChartDesign) != 0) //{ // createMenuByType(XtraContextMenuType.ChartDesign); //} if ((menuTypes & XtraContextMenuType.ViewControl) != 0) { createMenuByType(XtraContextMenuType.ViewControl); } if ((menuTypes & XtraContextMenuType.Print) != 0) { createMenuByType(XtraContextMenuType.Print); } if ((menuTypes & XtraContextMenuType.Export) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.Export); } if ((menuTypes & XtraContextMenuType.ExportAsTemplet) != 0) { createMenuByType(XtraContextMenuType.ExportAsTemplet); } if ((menuTypes & XtraContextMenuType.DataImport) != 0) { createMenuByType(XtraContextMenuType.DataImport); } if ((menuTypes & XtraContextMenuType.SaveGridState) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.SaveGridState); } if ((menuTypes & XtraContextMenuType.ColumnsAllowSort) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.ColumnsAllowSort); } if ((menuTypes & XtraContextMenuType.ExcelEdit) != 0) { if (_GridMenu.MenuItems.Count > 0) { _GridMenu.MenuItems.Add("-"); } createMenuByType(XtraContextMenuType.ExcelEdit); } }
public XtraPivotMenu(string text, XtraContextMenuType menuType) : base(text) { _MenuType = menuType; }