protected override void Invoke(object parameter) { RoutedEventArgs eventArgs = parameter as RoutedEventArgs; if (eventArgs != null) { ComboBox current = eventArgs.OriginalSource as ComboBox; string calcName = ""; Grid parentGrid = this.Target.Children.Count > 1 ? this.Target.Children[1] as Grid : null; PivotGridControl pivot = parentGrid != null ? parentGrid.Children[0] as PivotGridControl : null; int index = current.Name == "DisplayOptionBox" ? 1 : 0; calcName = index == 0 ? "Amount" : "Quantity"; if (pivot != null && current != null) { index = pivot.PivotCalculations.IndexOf(pivot.PivotCalculations.FirstOrDefault(x => x.FieldName == calcName)); if (index != -1) { switch (current.SelectedItem.ToString()) { case "None": pivot.PivotCalculations[index].DisplayOption = DisplayOption.None; break; case "All": pivot.PivotCalculations[index].DisplayOption = DisplayOption.All; break; case "Calculations": pivot.PivotCalculations[index].DisplayOption = DisplayOption.Calculations; break; case "Summaries": pivot.PivotCalculations[index].DisplayOption = DisplayOption.Summary; break; case "GrandTotals": pivot.PivotCalculations[index].DisplayOption = DisplayOption.GrandTotals; break; case "Summaries and Calculations": pivot.PivotCalculations[index].DisplayOption = DisplayOption.Calculations | DisplayOption.Summary; break; case "Summaries and GrandTotals": pivot.PivotCalculations[index].DisplayOption = DisplayOption.Summary | DisplayOption.GrandTotals; break; case "Calculations and GrandTotals": pivot.PivotCalculations[index].DisplayOption = DisplayOption.Calculations | DisplayOption.GrandTotals; break; } pivot.InternalGrid.Refresh(true); } else { current.SelectedIndex = 1; } } } }
private void button1_Click(object sender, EventArgs e) { PivotGridControl pivot = pivotGridControl1; if (pivot.Cells.Selection.IsEmpty) { pivotGridControl1.ExportToXlsx(fileName); } else { Rectangle selection = pivot.Cells.Selection; Point fCell = pivot.Cells.FocusedCell; pivot.Tag = selection; pivot.CustomFieldValueCells += pivotGridControl1_CustomFieldValueCells; try { pivot.RefreshData(); pivot.ExportToXlsx(fileName); } finally { pivot.CustomFieldValueCells -= pivotGridControl1_CustomFieldValueCells; pivot.RefreshData(); pivot.Cells.FocusedCell = fCell; pivot.Cells.Selection = selection; } } System.Diagnostics.Process.Start(fileName); }
private void Export_All_PivotGrid() { PivotGridControl[] grids = new PivotGridControl[] { pivotGridControl1 }; DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem(); DevExpress.XtraPrintingLinks.CompositeLink compositeLink = new DevExpress.XtraPrintingLinks.CompositeLink(ps); // Show the Document Map toolbar button and menu item. ps.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.All); // Make the "Export to Csv" and "Export to Txt" commands visible. ps.SetCommandVisibility(new PrintingSystemCommand[] { PrintingSystemCommand.ExportCsv, PrintingSystemCommand.ExportTxt, PrintingSystemCommand.ExportXlsx, PrintingSystemCommand.ExportDocx, PrintingSystemCommand.ExportXls }, CommandVisibility.All); compositeLink.PrintingSystem = ps; foreach (PivotGridControl grid in grids) { PrintableComponentLink link = new PrintableComponentLink(); link.Component = grid; //compositeLink.Links.Add(link); compositeLink.Links.AddRange(new object[] { link }); } string ReportName = "Daily_Status_Report"; string folderPath = "C:\\Temp\\"; string Path1 = folderPath + DateTime.Now.ToString("dd-MM-yyyy-hh-mm-ss") + "-" + ReportName + ".xlsx"; compositeLink.PrintingSystem.ExportToXlsx(Path1, new XlsxExportOptions() { ExportMode = XlsxExportMode.SingleFilePageByPage }); compositeLink.ShowPreview(); compositeLink.CreatePageForEachLink(); }
private void pivotGridControl1_CustomCellDisplayText(object sender, PivotCellDisplayTextEventArgs e) { PivotGridControl pivot = sender as PivotGridControl; if (e.DataField == fieldPercent) { List <object> rowValues = new List <object>(); foreach (PivotGridField field in e.GetRowFields()) { rowValues.Add(UpdateValue(field, e.RowIndex, e)); } List <object> columnValues = new List <object>(); foreach (PivotGridField field in e.GetColumnFields()) { columnValues.Add(UpdateValue(field, e.ColumnIndex, e)); } object previousValue = e.GetCellValue(columnValues.ToArray(), rowValues.ToArray(), e.DataField); if (previousValue == null) { e.DisplayText = string.Empty; } else if (Convert.ToDecimal(previousValue) == 0) { e.DisplayText = "err"; } else { e.DisplayText = (Convert.ToDecimal(e.Value) / Convert.ToDecimal(previousValue) - 1).ToString("P"); } } }
private string GetColumnFieldValueText(PivotGridControl pivotGrid, PivotCellEventArgs cellInfo) { StringBuilder sb = new StringBuilder(); if (cellInfo.ColumnValueType == PivotGridValueType.GrandTotal) { sb.Append("Grand Total"); sb.Append(separatorString); } else { foreach (PivotGridField field in cellInfo.GetColumnFields()) { sb.Append(cellInfo.GetFieldValue(field)); sb.Append(separatorString); } } if (pivotGrid.GetFieldsByArea(PivotArea.DataArea).Count > 1) { sb.Append(cellInfo.DataField); } else { sb.Remove(sb.Length - separatorString.Length, separatorString.Length); } return(sb.ToString()); }
/// <summary> /// 获取布局数据 /// </summary> /// <param name="dockManager">停靠管理器</param> /// <returns>布局数据</returns> public static byte[] GetLayoutData(this PivotGridControl control) { using (MemoryStream buffer = new MemoryStream()) { control.SaveLayoutToStream(buffer, OptionsLayoutBase.FullLayout); return(buffer.ToArray()); } }
protected override void OnAttached() { base.OnAttached(); AssociatedObject.DataContext = new ViewModel(); pivotGrid = AssociatedObject.Children[1] is Grid ? (AssociatedObject.Children[1] as Grid).Children[0] as PivotGridControl : null; scrollViewer = AssociatedObject.Children[1] is Grid ? (AssociatedObject.Children[1] as Grid).Children[1] as ScrollViewer : null; if (pivotGrid != null) { pivotGrid.AutoSizeOption = GridAutoSizeOption.None; var m = new MonthComparer("MMM"); pivotGrid.PivotColumns.Add(new PivotItem { FieldHeader = "Month", Comparer = m, FieldMappingName = "Date", TotalHeader = "Total", Format = "MMM" }); pivotGrid.PivotEngine.EnableOnDemandCalculations = pivotGrid.PivotEngine.UseIndexedEngine = true; pivotGrid.PivotEngine.GetValue = ItemObjectLookup; ObservableCollection <ItemObject> itemsSourceObject = (AssociatedObject.DataContext as ViewModel).ItemObjectCollection; pivotGrid.PivotEngine.PivotSchemaChanged += PivotEngine_PivotSchemaChanged; pivotGrid.ItemSource = itemsSourceObject; } }
private static string GetDimensionsString(PivotGridControl pivot) { string dimensionString = string.Empty; bool _isFirstItem = true; foreach (PivotGridField field in pivot.Fields) { if (field.Area == PivotArea.DataArea || field.Visible == false || field.InnerGroupIndex > 0) { continue; } if (!_isFirstItem) { dimensionString = dimensionString + _dimensionSeparator; } else { _isFirstItem = false; } if (field.InnerGroupIndex < 0) { dimensionString = dimensionString + GetDimensionName(field); } else { dimensionString = dimensionString + GetHierarchyString(pivot, field); } } return(dimensionString); }
public static void ExportTo(this PivotGridControl pvtGrid, string fileName, bool openAfterExport = false) { var ext = new FileInfo(fileName).Extension; switch (ext) { case ".csv": pvtGrid.ExportToCsv(fileName); break; case ".htm": case ".html": pvtGrid.ExportToHtml(fileName); break; case ".bmp": pvtGrid.ExportToImage(fileName); break; case ".mht": pvtGrid.ExportToMht(fileName); break; case ".pdf": pvtGrid.ExportToPdf(fileName); break; case ".rtf": pvtGrid.ExportToRtf(fileName); break; case ".txt": pvtGrid.ExportToText(fileName); break; case ".xls": pvtGrid.ExportToXls(fileName); break; case ".xlsx": pvtGrid.ExportToXlsx(fileName); break; default: throw new Exception("გთხოვთ აირჩიოთ სწორი ფაილის ტიპი."); } if (openAfterExport) { try { Process.Start(fileName); } catch { //if (throwError) throw; } } }
private void chartControl1_ObjectHotTracked(object sender, DevExpress.XtraCharts.HotTrackEventArgs e) { SeriesPoint point = e.AdditionalObject as SeriesPoint; if (point != null) { PivotChartDataSourceRowItem coord = point.Tag as PivotChartDataSourceRowItem; ChartControl chart = (ChartControl)sender; PivotGridControl pivot = (PivotGridControl)chart.DataSource; PivotCellEventArgs info = pivot.Cells.GetCellInfo(coord.CellX, coord.CellY); PivotSummaryDataSource source = info.CreateSummaryDataSource(); string s = string.Empty; for (int i = 0; i < source.RowCount; i++) { s += "Country = " + source.GetValue(i, 0).ToString() + "\r\tYear = " + source.GetValue(i, 1).ToString() + "\r\tExtended Price = " + source.GetValue(i, 2).ToString() + "\r\n"; } toolTipController1.ShowHint(s); } else { toolTipController1.HideHint(); } }
void SetMenuManager(ControlCollection controlCollection, IDXMenuManager manager) { foreach (Control ctrl in controlCollection) { GridControl gridControl = ctrl as GridControl; if (gridControl != null) { gridControl.MenuManager = manager; break; } PivotGridControl pivot = ctrl as PivotGridControl; if (pivot != null) { pivot.MenuManager = manager; break; } BaseEdit edit = ctrl as BaseEdit; if (edit != null) { edit.MenuManager = manager; break; } SetMenuManager(ctrl.Controls, manager); } }
private void pivotGridControl1_CustomSummary(object sender, PivotGridCustomSummaryEventArgs e) { if (ReferenceEquals(e.DataField, fieldProductAmount1)) { // This is a Grand Total cell. if (ReferenceEquals(e.ColumnField, null) || ReferenceEquals(e.RowField, null)) { e.CustomValue = "Grand Total"; return; } PivotGridControl pivot = sender as PivotGridControl; int lastRowFieldIndex = pivot.Fields.GetVisibleFieldCount(PivotArea.RowArea) - 1; int lastColumnFieldIndex = pivot.Fields.GetVisibleFieldCount(PivotArea.ColumnArea) - 1; // This is an ordinary cell. if (e.RowField.AreaIndex == lastRowFieldIndex && e.ColumnField.AreaIndex == lastColumnFieldIndex) { e.CustomValue = e.SummaryValue.Average; } // This is a Total cell. else { e.CustomValue = "Total"; } } }
private static void UpdatePivotSelection(PivotGridControl pivot, string fieldName, object value) { PivotGridField field = pivot.Fields[fieldName]; if (field.Area == PivotArea.DataArea || field.Area == PivotArea.FilterArea) { pivot.Cells.Selection = Rectangle.Empty; } int count = field.Area == PivotArea.ColumnArea ? pivot.Cells.ColumnCount : pivot.Cells.RowCount; List <int> range = new List <int>(); for (int i = 0; i < count; i++) { if (Comparer.Default.Compare(value, pivot.GetFieldValue(field, i)) == 0) { range.Add(i); } } if (range.Count == 0) { return; } pivot.Cells.Selection = field.Area == PivotArea.ColumnArea ? new Rectangle(range[0], 0, range.Count, pivot.Cells.RowCount) : new Rectangle(0, range[0], pivot.Cells.ColumnCount, range.Count); ((IPivotGridViewInfoDataOwner)pivot).DataViewInfo.ViewInfo.LeftTopCoord = pivot.Cells.Selection.Location; }
public ReorderHelper(PivotGridControl pivot) { AllowChangeRowGroup = false; AllowChangeColumnGroup = false; AllowDragColumn = false; Attach(pivot); }
static void FillDatasetColumns(PivotGridControl pivot, DataTable dataTable1) { dataTable1.Columns.Add("RowFields", typeof(string)); StringBuilder sb = new StringBuilder(); List <PivotGridField> fieldsInColumnArea = GetFieldsInArea(pivot, FieldArea.ColumnArea); bool multipleDataField = pivot.GetFieldsByArea(FieldArea.DataArea).Count > 1; for (int i = 0; i < pivot.ColumnCount; i++) { PivotCellBaseEventArgs pcea = pivot.GetCellInfo(i, 0); foreach (PivotGridField field in pcea.GetColumnFields()) { sb.AppendFormat("{0} | ", field.GetDisplayText(pcea.GetFieldValue(field)));//add formatting if it's necessary } if (multipleDataField) { sb.AppendFormat("{0} | ", pcea.DataField); } if (pcea.ColumnValueType == FieldValueType.Value) { sb.Remove(sb.Length - 3, 3); } else { sb.Append(pcea.ColumnValueType.ToString()); } dataTable1.Columns.Add(sb.ToString(), typeof(object)); sb.Clear(); } }
static public void SaveXml(PivotGridControl pivotGrid, string dirPath, string fileName) { try { DataSet ds = GetLayOutFromPivotGrid(pivotGrid); if (ds == null) { return; } if (ValidateItemPath(dirPath, true) == false) { return; } string filePath = string.Format("{0}\\{1}", dirPath, fileName); FileStream stream = new FileStream(filePath, FileMode.Create); XmlTextWriter xmlWriter = new XmlTextWriter(stream, System.Text.Encoding.Unicode); ds.WriteXml(xmlWriter); xmlWriter.Close(); stream.Close(); } catch { } }
private void ShowTotal(PivotGridControl pivot)//, bool isCheck) { pivot.OptionsView.ShowRowTotals = true; pivot.OptionsView.ShowRowGrandTotals = true; pivot.OptionsView.ShowColumnTotals = true; pivot.OptionsView.ShowColumnGrandTotals = true; }
private static string GetLastLevelFieldName(PivotGridControl pivot, PivotGridField field) { PivotGridGroup group = pivot.Groups[field.GroupIndex]; PivotGridFieldBase lastLevelField = group[group.Count - 1]; return(lastLevelField.FieldName); }
public static string GetQueryString(PivotGridControl pivot, string fullConnectionString, bool nonEmptyBehavior) { OLAPConnectionStringBuilder builder = new OLAPConnectionStringBuilder(fullConnectionString); string cubeName = builder.CubeName; return(_select + GetNonEmptyString(nonEmptyBehavior) + GetMeasuresString(pivot) + _onColumns + _parametersSeparator + GetNonEmptyString(nonEmptyBehavior) + GetDimensionsString(pivot) + _onRows + _from + SquareBrackets(cubeName)); }
public PopupChartOption(PivotGridControl _pivotGridMaster, string _chartTitle) { InitializeComponent(); pivotGridMaster = _pivotGridMaster; chartTitle = _chartTitle.ToUpper(); _initLoaiBieuDo(); _initChart(); }
public void DoPivoitPrint(PivotGridControl pivotGridControl, bool landscape = true) { var link = new PrintableComponentLink(new PrintingSystem()) { Margins = { Left = 10, Right = 10, Top = 110, Bottom = 90 }, Landscape = landscape, PaperKind = PaperKind.A4, Component = pivotGridControl }; var footer = new PageFooterArea(); footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username); footer.Content.Add("Page " + "[Page #]"); footer.LineAlignment = BrickAlignment.Near; var header = new PageHeaderArea(); link.CreateMarginalHeaderArea += CreateMarginalDetailHeaderArea; link.CreateMarginalFooterArea += CreateMarginalFooterArea; link.PageHeaderFooter = new PageHeaderFooter(header, footer); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None); link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible = false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible = false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible = false; link.CreateDocument(); link.PrintingSystem.Document.AutoFitToPagesWidth = 1; link.ShowRibbonPreview(UserLookAndFeel.Default); }
public static Point[] GetSelectedCell(PivotGridControl grid) { if (grid.Cells.MultiSelection.SelectedCells.Count > 0) { Point[] pointArray = new Point[grid.Cells.MultiSelection.SelectedCells.Count]; int num = 0; foreach (Point point in grid.Cells.MultiSelection.SelectedCells) { if (point != null) { pointArray[num++] = point; } } return pointArray; } return null; }
public static void AddMenuToGridView(PivotGridControl grid, string fieldName, string[] captions, string[] images, DelegationLib.CallFunction_MulIn_NoOut[] delegates, PermissionItem[] pers) { EventHandler handler = null; if (captions != null) { ContextMenuStrip strip = new ContextMenuStrip(); int index = 0; foreach (string str in captions) { bool? nullable; if (((pers != null) && (pers[index] != null)) && !(ApplyPermissionAction.checkPermission(pers[index]).HasValue && !(!(nullable = ApplyPermissionAction.checkPermission(pers[index])).GetValueOrDefault() && nullable.HasValue))) { index++; } else { Image image = null; image = ResourceMan.getImage16(images[index]); ToolStripMenuItem item = new ToolStripMenuItem(str, image); item.Name = index.ToString(); if (handler == null) { handler = new EventHandler(delegate(object sender, EventArgs e) { List<object> data = new List<object>(); foreach (Point point in grid.Cells.MultiSelection.SelectedCells) { data.Add(point); } delegates[(int)((IntPtr)HelpNumber.ParseInt64(((ToolStripMenuItem)sender).Name))](data); }); } item.Click += handler; strip.Items.Add(item); index++; } } grid.ContextMenuStrip = strip; } }
public static void ShowMenu(BarSubItem barSubItem1, bool _status, PivotGridControl pivotGridMaster, SplitContainerControl splitContainerControl1) { barSubItem1.Enabled = _status; if (pivotGridMaster.ContextMenuStrip != null) { foreach (ToolStripItem item in pivotGridMaster.ContextMenuStrip.Items) { item.Enabled = _status; } } }
public static void CreateBusinessMenu(PivotGridControl gridMaster, BarSubItem barSubItem1, string fieldName, string[] captions, string[] ImageNames, DelegationLib.CallFunction_MulIn_NoOut[] delegates, PermissionItem[] pers) { ItemClickEventHandler handler = null; if (captions == null) { barSubItem1.Visibility = BarItemVisibility.Never; } else { int index = 0; foreach (string str in captions) { bool? nullable; if (((pers != null) && (pers[index] != null)) && !(ApplyPermissionAction.checkPermission(pers[index]).HasValue && !(!(nullable = ApplyPermissionAction.checkPermission(pers[index])).GetValueOrDefault() && nullable.HasValue))) { index++; } else { BarButtonItem item = new BarButtonItem(); item.Caption = captions[index]; item.Name=index.ToString(); if (!ImageNames[index].Equals("")) { item.Glyph=ResourceMan.getImage16(ImageNames[index]); } item.PaintStyle = BarItemPaintStyle.Standard; if (handler == null) { handler += new ItemClickEventHandler(delegate(object sender, ItemClickEventArgs e) { if (gridMaster.Cells.MultiSelection.SelectedCells.Count < 1) { HelpMsgBox.ShowNotificationMessage(""); } else { List<object> data = new List<object>(); foreach (Point point in gridMaster.Cells.MultiSelection.SelectedCells) { data.Add(point); } delegates[HelpNumber.ParseInt32(e.Item.Name)](data); } }); } item.ItemClick += handler; barSubItem1.ItemLinks.Add(item); index++; } } if ((barSubItem1.ItemLinks == null) || (barSubItem1.ItemLinks.Count == 0)) { barSubItem1.Visibility = BarItemVisibility.Never; } } }
void PLLoadMasterPart(PivotGridControl MasterGrid) { try { DataSet set = DABase.getDatabase().LoadReadOnlyDataSet(this.that.filter); this.that.barButtonItemExport.Enabled = ((set != null && set.Tables.Count > 0 && set.Tables[0].Rows.Count > 0) ? true : false); this.that.barItemIn.Enabled = this.that.barButtonItemExport.Enabled; this.that.barButtonItemSearch.Enabled = this.that.barButtonItemExport.Enabled; MasterGrid.DataSource = set.Tables[0]; } catch (Exception exception) { PLException.AddException(exception); } }
private void CopyArea(PivotGridControl control, FieldArea area) { foreach (var field in control.GetFieldsByArea(area)) { PivotGridField f = field.FieldName.Equals("MEASURE_STATUS") ? Fields["MEASURE_STATUS_NEW"] : Fields[field.FieldName]; f.Visible = true; f.Area = area; if (field.FieldName.Contains("LOC")) { f.FilterValues.ValuesIncluded = field.GetVisibleValues().ToArray(); } else if (field.FieldName.Contains("MEASURE") == false) { if (field.FilterValues.HasFilter) { f.FilterValues.ValuesIncluded = field.FilterValues.ValuesIncluded; } } } }
public static RepositoryItemCheckedComboBoxEdit AddTuyBienCot(BarManager barManager, Bar menuBar, PivotGridControl pivot,PivotGridField[] choseFields, bool[] defaultCheck) { RepositoryItemCheckedComboBoxEdit repositoryItemCheckedCotHienThi = new RepositoryItemCheckedComboBoxEdit(); // // repositoryItemCheckedCotHienThi // repositoryItemCheckedCotHienThi.AutoHeight = false; repositoryItemCheckedCotHienThi.BestFitWidth = 180; repositoryItemCheckedCotHienThi.Name = "repositoryItemCheckedCotHienThi"; // BarEditItem barEditItemCotHienThi = new BarEditItem(); // // barEditItemCotHienThi // barEditItemCotHienThi.Caption = "&Cột hiển thị"; barEditItemCotHienThi.Edit = repositoryItemCheckedCotHienThi; barEditItemCotHienThi.Name = "barEditItem1"; barEditItemCotHienThi.PaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph; barEditItemCotHienThi.Width = 200; // barManager.Items.Add(barEditItemCotHienThi); barManager.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { repositoryItemCheckedCotHienThi}); // menuBar.LinksPersistInfo.Add(new DevExpress.XtraBars.LinkPersistInfo(barEditItemCotHienThi, true)); //Gán các cột vào CheckedComboBox PivotGridField field = null; StringBuilder text = new StringBuilder(); for (int i = 0; i < choseFields.Length; i++) { field = choseFields[i]; if (defaultCheck[i]) { repositoryItemCheckedCotHienThi.Items.Add(field.Name, field.Caption, CheckState.Checked, true); field.Visible = true; text.Append(" " + field.Caption + repositoryItemCheckedCotHienThi.SeparatorChar); } else { repositoryItemCheckedCotHienThi.Items.Add(field.Name, field.Caption, CheckState.Unchecked, true); field.Visible = false; } } repositoryItemCheckedCotHienThi.SynchronizeEditValueWithCheckedItems = false; barEditItemCotHienThi.EditValue = text.ToString().TrimEnd(repositoryItemCheckedCotHienThi.SeparatorChar); //------------------------------- // repositoryItemCheckedCotHienThi.CloseUp += delegate(object sender, DevExpress.XtraEditors.Controls.CloseUpEventArgs e) { StringBuilder value = new StringBuilder(); foreach (CheckedListBoxItem item in (sender as CheckedComboBoxEdit).Properties.Items) { if (item.CheckState == System.Windows.Forms.CheckState.Checked) { value.Append(" " + item.Description + (sender as CheckedComboBoxEdit).Properties.SeparatorChar.ToString()); } } if (value.Length > 0) e.Value = value.ToString().Remove(value.Length - 1); else e.Value = string.Empty; }; //Set các cột hiển thị mặc định //if (choseFields != null) //{ // List<string> listDefaultField = new List<string>(choseFields); // StringBuilder displayText = new StringBuilder(); // for (int i = 0; i < repositoryItemCheckedCotHienThi.Items.Count; i++) // { // if (listDefaultField.Contains(repositoryItemCheckedCotHienThi.Items[i].Value.ToString())) // { // repositoryItemCheckedCotHienThi.Items[i].CheckState = System.Windows.Forms.CheckState.Checked; // displayText.Append(" " + repositoryItemCheckedCotHienThi.Items[i].Description + repositoryItemCheckedCotHienThi.SeparatorChar.ToString()); // } // } // if (displayText.ToString() != string.Empty) // barEditItemCotHienThi.EditValue = displayText.ToString().Remove(displayText.Length - 1); // repositoryItemCheckedCotHienThi.SynchronizeEditValueWithCheckedItems = false; // DisplayTheoTuyBienCot(gridView, repositoryItemCheckedCotHienThi); //} return repositoryItemCheckedCotHienThi; }
private void InitializeComponent() { this.pivotGridControl1 = new PivotGridControl(); this.pivotGridField1 = new PivotGridField(); this.pivotGridField2 = new PivotGridField(); this.pivotGridField3 = new PivotGridField(); this.pivotGridField4 = new PivotGridField(); this.pivotGridField5 = new PivotGridField(); this.pivotGridField6 = new PivotGridField(); this.pivotGridField7 = new PivotGridField(); this.pivotGridControl1.BeginInit(); base.SuspendLayout(); base.ttDefault.DefaultController.AutoPopDelay = 0x3e8; this.pivotGridControl1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top; this.pivotGridControl1.Cursor = Cursors.Default; this.pivotGridControl1.Fields.AddRange(new PivotGridField[] { this.pivotGridField1, this.pivotGridField2, this.pivotGridField3, this.pivotGridField4, this.pivotGridField5, this.pivotGridField6, this.pivotGridField7 }); this.pivotGridControl1.Location = new Point(0x1a, 0x5f); this.pivotGridControl1.LookAndFeel.SkinName = "Money Twins"; this.pivotGridControl1.LookAndFeel.UseDefaultLookAndFeel = false; this.pivotGridControl1.Name = "pivotGridControl1"; this.pivotGridControl1.OptionsDataField.Area = PivotDataArea.ColumnArea; this.pivotGridControl1.OptionsDataField.DataFieldArea = PivotArea.ColumnArea; this.pivotGridControl1.OptionsDataField.DataFieldAreaIndex = 0; this.pivotGridControl1.OptionsDataField.DataFieldVisible = true; this.pivotGridControl1.Size = new Size(0x298, 0x15c); this.pivotGridControl1.TabIndex = 7; this.pivotGridField1.Area = PivotArea.DataArea; this.pivotGridField1.AreaIndex = 0; this.pivotGridField1.FieldName = "built"; this.pivotGridField1.Name = "pivotGridField1"; this.pivotGridField1.UnboundType = UnboundColumnType.Integer; this.pivotGridField2.Area = PivotArea.DataArea; this.pivotGridField2.AreaIndex = 1; this.pivotGridField2.FieldName = "lost"; this.pivotGridField2.Name = "pivotGridField2"; this.pivotGridField2.UnboundType = UnboundColumnType.Integer; this.pivotGridField3.Area = PivotArea.DataArea; this.pivotGridField3.AreaIndex = 2; this.pivotGridField3.FieldName = "killed"; this.pivotGridField3.Name = "pivotGridField3"; this.pivotGridField3.UnboundType = UnboundColumnType.Integer; this.pivotGridField4.Area = PivotArea.DataArea; this.pivotGridField4.AreaIndex = 3; this.pivotGridField4.FieldName = "damage_dealt"; this.pivotGridField4.Name = "pivotGridField4"; this.pivotGridField4.UnboundType = UnboundColumnType.Decimal; this.pivotGridField5.Area = PivotArea.DataArea; this.pivotGridField5.AreaIndex = 4; this.pivotGridField5.FieldName = "damage_received"; this.pivotGridField5.Name = "pivotGridField5"; this.pivotGridField5.UnboundType = UnboundColumnType.Decimal; this.pivotGridField6.Area = PivotArea.RowArea; this.pivotGridField6.AreaIndex = 0; this.pivotGridField6.FieldName = "player_name"; this.pivotGridField6.Name = "pivotGridField6"; this.pivotGridField6.UnboundType = UnboundColumnType.String; this.pivotGridField7.Area = PivotArea.RowArea; this.pivotGridField7.AreaIndex = 1; this.pivotGridField7.FieldName = "unit_name"; this.pivotGridField7.Name = "pivotGridField7"; this.pivotGridField7.UnboundType = UnboundColumnType.String; base.AutoScaleDimensions = new SizeF(7f, 13f); base.AutoScaleMode = AutoScaleMode.Font; base.ClientSize = new Size(0x2dd, 0x207); base.Controls.Add(this.pivotGridControl1); this.Font = new Font("Verdana", 8f); base.Location = new Point(0, 0); base.Name = "DlgSupcomStats"; this.Text = "DlgSupcomStats"; base.Controls.SetChildIndex(this.pivotGridControl1, 0); this.pivotGridControl1.EndInit(); base.ResumeLayout(false); base.PerformLayout(); }
public static string ExportToExcel(PivotGridControl pivot) { return ExportToExcel(pivot, TextExportMode.Value); }
void SetEditor(PivotGridField field, PivotGridControl sender) { if (field.Area == PivotArea.DataArea && field.DataType.IsPrimitive) { field.FieldEdit = _repositoryItemSpinEdits[sender]; } }
public WindowRowOriented(Session session, PivotGridControl pivotGridControl1) { InitializeComponent(); #region Initialize _session = session; _closeWithoutCheck = false; _db = _session.GetDbManager(); _doc = _session.GetDocument(); //ThemeManager.SetThemeName(this, "Office2007Silver"); ThemeManager.SetThemeName(this, "DeepBlue"); WindowState = WindowState.Maximized; Closing += WindowSecondaryClosing; _doc.DocProjected += DbDocProjected; var desc = _doc.Description; Title = "Документ: " + (desc ?? "не создан") + " (" + _doc.Id + ", " + DocTypes.Description(_doc.DocType) + ")"; //Title = "Документ: " + (desc.Equals("") ? "не создан" : desc) + " (" + _doc.Id + ", " + (_doc.DocType == DocTypes.Operative ? "Оперативный" : "Обычный") + ")"; try { _db.FillDataTableCustom(Table.TableSupplier.Name, Table.TableSupplier.SelectClause, Table.TableSupplier.KeyFields, false); } catch (AssortmentException ex) { MessageBox.Show(Table.TableSupplier + ": " + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* if (_db.FillDataTableCustom(Table.TableSupplier.Name, Table.TableSupplier.SelectClause, Table.TableSupplier.KeyFields, false) == false) { MessageBox.Show("Ошибка при формировании источника: " + _db.Error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } */ #endregion #region Initialize PivotGrid Control try { _db.FillDataTableCustom(Table.TableRowSource); } catch (AssortmentException ex) { MessageBox.Show(Table.TableRowSource + ": " + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); return; } /* if (_db.FillDataTableCustom(Table.TableRowSource) == false) { MessageBox.Show("Ошибка при формировании источника: " + _db.Error, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } */ _pivotGridControl2.DataSource = _db.DataTableGet(Table.TableRowSource.Name).DefaultView; _pivotGridControl2.HiddenFieldList += PivotGridControl2HiddenFieldList; var dimensions = _db.GetTableDefinition(Table.TableRowSource.DBName); if (dimensions == null) { MessageBox.Show("Список измерений для данной таблицы пуст", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } else { _pivotGridControl2.InitializeControl(dimensions, _db); } _pivotGridControl2.InitializeLayout(pivotGridControl1); _pivotGridControl2.ShowRowTotals = false; _pivotGridControl2.ShowColumnTotals = false; _pivotGridControl2.ShowColumnGrandTotals = false; _pivotGridControl2.ShowRowGrandTotals = false; _pivotGridControl2.CellClickInputData += PivotGridControl2CellClickInputData; _pivotGridControl2.BestFit(); #endregion }
PivotCellEventArgs GetFocusedCellInfo(PivotGridControl pivot) { Point focused = pivot.Cells.FocusedCell; return pivot.Cells.GetCellInfo(focused.X, focused.Y); }
public static bool _set(PivotGridControl pivotGrid, FieldPivot[] fieldPivots, PivotArea pivotArea) { foreach (FieldPivot field in fieldPivots) { PivotGridField _field = new PivotGridField(); _field.Area = pivotArea; if (!_setField(field, _field)) { PLMessageBox.ShowErrorMessage( (pivotArea == PivotArea.RowArea ? "Row" : (pivotArea == PivotArea.ColumnArea ? "Column" : "Data")) + "Field cấu hình không đúng."); return false; } pivotGrid.Fields.Add(_field); } return true; }
public static void VietHoaMenuGridPivot(PivotGridControl pivotGridMaster) { pivotGridMaster.ShowMenu += delegate(object sender, PivotGridMenuEventArgs e) { if (e.MenuType == PivotGridMenuType.Header) { foreach (DevExpress.Utils.Menu.DXMenuItem item in e.Menu.Items) { if (item.Caption.Equals("Refresh Data")) item.Caption = "Làm tươi dữ liệu"; else if (item.Caption.Equals("Hide")) item.Caption = "Ẩn"; else if (item.Caption.Equals("Order")) { item.Caption = "Sắp xếp"; try { DevExpress.Utils.Menu.DXSubMenuItem subitem = (DevExpress.Utils.Menu.DXSubMenuItem)item; foreach (DevExpress.Utils.Menu.DXMenuItem subitemOrder in subitem.Items) { if (subitemOrder.Caption.Equals("Move to Beginning")) subitemOrder.Caption = "Di chuyển về đầu"; else if (subitemOrder.Caption.Equals("Move to Left")) subitemOrder.Caption = "Di chuyển sang trái"; else if (subitemOrder.Caption.Equals("Move to Right")) subitemOrder.Caption = "Di chuyển sang phải"; if (subitemOrder.Caption.Equals("Move to End")) subitemOrder.Caption = "Di chuyển về cuối"; } } catch { } } else if (item.Caption.Equals("Show Field List")) item.Caption = "Xem danh sách cột ẩn"; else if (item.Caption.Equals("Show Prefilter")) item.Caption = "Xem điều kiện lọc"; } } else if (e.MenuType == PivotGridMenuType.FieldValue) { foreach (DevExpress.Utils.Menu.DXMenuItem item in e.Menu.Items) { if (item.Caption.Contains("by This Column")) { string[] caption = item.Caption.Split(new string[] { "Sort ", " by This Column" }, StringSplitOptions.RemoveEmptyEntries);//Sort \"Tên hàng hóa\" by This Column item.Caption = "Sắp xếp " + caption[0] + " theo cột này"; } else if (item.Caption.Contains("by This Row")) { string[] caption = item.Caption.Split(new string[] { "Sort ", " by This Row" }, StringSplitOptions.RemoveEmptyEntries);//Sort \"Tên hàng hóa\" by This Column item.Caption = "Sắp xếp " + caption[0] + " theo dòng này"; } else if (item.Caption.Equals("Collapse")) item.Caption = "Đóng nhóm"; else if (item.Caption.Equals("Collapse All")) item.Caption = "Đóng tất cả nhóm"; else if (item.Caption.Equals("Expand All")) item.Caption = "Mở tất cả nhóm"; else if (item.Caption.Equals("Expand")) item.Caption = "Mở nhóm"; } } else if (e.MenuType == PivotGridMenuType.HeaderArea) { foreach (DevExpress.Utils.Menu.DXMenuItem item in e.Menu.Items) { if (item.Caption.Equals("Refresh Data")) item.Caption = "Làm tươi dữ liệu"; else if (item.Caption.Equals("Show Field List")) item.Caption = "Xem danh sách cột ẩn"; else if (item.Caption.Equals("Hide Field List")) item.Caption = "Ẩn danh sách cột"; else if (item.Caption.Equals("Show Prefilter")) item.Caption = "Xem điều kiện lọc"; } } }; }
public static void SetContextMenuOnGrid(PivotGridControl pivotGridMaster, _MenuItem AppendMenu, _MenuItem NghiepVuMenu, bool IncludeNghiepVu) { try { _MenuItem item = null; if (IncludeNghiepVu) { if ((NghiepVuMenu == null) && (AppendMenu != null)) { item = AppendMenu; } else if ((NghiepVuMenu != null) && (AppendMenu == null)) { item = NghiepVuMenu; } else if ((NghiepVuMenu == null) && (AppendMenu == null)) { item = null; } } else { item = AppendMenu; } if (item != null) { HelpPivotGrid.AddMenuToGridView(pivotGridMaster, item.FieldName, item.CaptionNames, item.ImageNames, item.Funcs); } } catch (Exception exception) { PLException.AddException(exception); } }
public static string ExportToExcel(PivotGridControl pivot, TextExportMode exportMode) { try { var fileName = GetSaveExcelFileName(); var extension = Path.GetExtension(fileName); if (extension == ".xls") { pivot.ExportToXls(fileName, new XlsExportOptions( exportMode, true)); } else if (extension == ".xlsx") { pivot.ExportToXlsx(fileName, new XlsxExportOptions( exportMode, true)); } else { return ""; } return fileName; } catch { } return ""; }
public void InitializeLayout(PivotGridControl control) { //Fields["ITEM"].Area = FieldArea.RowArea; //foreach (var field in control.GetFieldsByArea(FieldArea.RowArea)) //{ // if (field.FieldName.Contains("ITEMLOC")) continue; // PivotGridField f = Fields[field.FieldName]; // f.Visible = true; // f.Area = FieldArea.RowArea; //} // remove -1 (delete action) from the action field and it lock foreach (object t in Fields["ACTION"].FilterValues.ValuesIncluded) { if (Convert.ToInt32(t) == -1) { Fields["ACTION"].FilterValues.ValuesExcluded = new[] { t }; } } /* foreach (object t in Fields["DIM_LOC_TYPE"].FilterValues.ValuesIncluded) { if (Convert.ToChar(t) == (char)LocTypes.W) { Fields["DIM_LOC_TYPE"].FilterValues.ValuesExcluded = new[] { t }; } } */ Fields["ACTION"].Area = FieldArea.RowArea; Fields["ACTION"].Visible = true; Fields["ITEM"].Area = FieldArea.RowArea; Fields["ITEM"].Visible = true; Fields["DIM_ITEM_DESC"].Area = FieldArea.RowArea; Fields["DIM_ITEM_DESC"].Visible = true; Fields["DIM_LOC_TYPE"].Area = FieldArea.FilterArea; Fields["DIM_LOC_TYPE"].Visible = true; Fields["DIM_LOC_TYPE"].AllowDrag = false; //Fields["DIM_LOC_TYPE"].AllowFilter = false; Fields["DIM_LOC_CHAIN"].Area = FieldArea.FilterArea; Fields["DIM_LOC_CHAIN"].Visible = true; Fields["DIM_LOC_REGION"].Area = FieldArea.FilterArea; Fields["DIM_LOC_REGION"].Visible = true; Fields["DIM_LOC_FORMAT"].Area = FieldArea.FilterArea; Fields["DIM_LOC_FORMAT"].Visible = true; Fields["DIM_LOC_STANDARD"].Area = FieldArea.FilterArea; Fields["DIM_LOC_STANDARD"].Visible = true; Fields["LOC"].Area = FieldArea.FilterArea; Fields["LOC"].Visible = true; Fields["DIM_LOC_DESC"].Area = FieldArea.FilterArea; Fields["DIM_LOC_DESC"].Visible = true; Fields["DIM_ITEMLOC_SUPPLIER"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SUPPLIER_DESC"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SUPPLIER_NEW"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SUPPLIER_NEW"].Caption = "(NEW)Поставщик"; Fields["DIM_ITEMLOC_SUPPLIER_DESC_NEW"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SUPPLIER_DESC_NEW"].Caption = "(NEW)Поставщик.Название"; Fields["DIM_ITEMLOC_ORDERPLACE"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_ORDERPLACE_NEW"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_ORDERPLACE_NEW"].Caption = "(NEW)Место заказа"; Fields["DIM_ITEMLOC_SOURCEMETHOD"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SOURCEWH"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SOURCEMETHOD_NEW"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SOURCEMETHOD_NEW"].Caption = "(NEW)Метод поставки"; Fields["DIM_ITEMLOC_SOURCEWH_NEW"].Area = FieldArea.DataArea; Fields["DIM_ITEMLOC_SOURCEWH_NEW"].Caption = "(NEW)Склад поставки"; Fields["ITEM"].FilterValues.ValuesIncluded = control.Fields["ITEM"].GetVisibleValues().ToArray(); Fields["LOC"].FilterValues.ValuesIncluded = control.Fields["LOC"].GetVisibleValues().ToArray(); Fields["DIM_ITEMLOC_SUPPLIER"].Visible = true; Fields["DIM_ITEMLOC_SUPPLIER_DESC"].Visible = true; Fields["DIM_ITEMLOC_SUPPLIER_NEW"].Visible = true; Fields["DIM_ITEMLOC_SUPPLIER_DESC_NEW"].Visible = true; Fields["DIM_ITEMLOC_ORDERPLACE"].Visible = true; Fields["DIM_ITEMLOC_ORDERPLACE_NEW"].Visible = true; Fields["DIM_ITEMLOC_SOURCEMETHOD"].Visible = true; Fields["DIM_ITEMLOC_SOURCEWH"].Visible = true; Fields["DIM_ITEMLOC_SOURCEMETHOD_NEW"].Visible = true; Fields["DIM_ITEMLOC_SOURCEWH_NEW"].Visible = true; }
public void CopyLayout(PivotGridControl control) { CopyArea(control, FieldArea.ColumnArea); CopyArea(control, FieldArea.RowArea); CopyArea(control, FieldArea.DataArea); CopyArea(control, FieldArea.FilterArea); Fields["DIM_LOC_TYPE"].AllowDrag = false; Fields["DIM_LOC_TYPE"].AllowFilter = false; }
/// <summary> /// Hiển thị các cột đã được chọn /// </summary> /// <param name="gridView"></param> /// <param name="cotHienThi"></param> public static void DisplayTheoTuyBienCot(PivotGridControl pivot, RepositoryItemCheckedComboBoxEdit cotHienThi) { //gridView.ClearGrouping(); List<string> chekedItem = new List<string>(); List<string> allItem = new List<string>(); foreach (CheckedListBoxItem item in cotHienThi.Items) { allItem.Add(item.Value.ToString()); if (item.CheckState == CheckState.Checked) chekedItem.Add(item.Value.ToString()); } foreach (PivotGridField field in pivot.Fields) { if (allItem.Contains(field.Name) == false) continue; field.Visible = false; if (chekedItem.Contains(field.Name)) { field.Visible = true; // field.vi = i++; } // else field.Visible = false; } pivot.BestFit(); }
public static void AddMenuToGridView(PivotGridControl grid, string fieldName, string[] captions, string[] images, DelegationLib.CallFunction_MulIn_NoOut[] delegates) { AddMenuToGridView(grid, fieldName, captions, images, delegates, null); }