/// <summary> /// The Grid settings can be customized /// </summary> private void InitializePivotGrid() { // Adding ItemSource to the Control pivotGridControl1.ItemSource = ProductSalesData.GetSalesData(); // Adding PivotRows to the Control pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName = "Product", TotalHeader = "Total" }); pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName = "Date", TotalHeader = "Total" }); // Adding PivotColumns to the Control pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", TotalHeader = "Total" }); pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "State", TotalHeader = "Total" }); // Adding PivotCalculations to the Control pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Amount", Format = "$ #,##0.00", SummaryType = SummaryType.DoubleTotalSum }); pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Quantity", Format = "#,##0" }); }
/// <summary> /// Grid Settings for better look and feel /// </summary> private void InitializePivotGrid() { pivotGridControl1.TableControl.ThemesEnabled = true; pivotGridControl1.GridVisualStyles = GridVisualStyles.Metro; // Adding ItemSource to the Control pivotGridControl1.ItemSource = ProductSalesData.GetSalesData(); // Adding PivotRows to the Control pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName = "Product", TotalHeader = "Total" }); pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName = "Date", TotalHeader = "Total" }); // Adding PivotColumns to the Control pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", TotalHeader = "Total" }); pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "State", TotalHeader = "Total" }); // Adding PivotCalculations to the Control pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Amount", Format = "$ #,##0.00", SummaryType = SummaryType.DoubleTotalSum }); pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Quantity", Format = "#,##0" }); //tab key navigation set as false to move the next control pivotGridControl1.TableControl.WantTabKey = false; }