Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145874 | Jul 11,2019 06:13 PM UTC | Jul 15,2019 10:47 AM UTC | WinForms | 2 |
![]() |
Tags: PivotGridControl |
# Form1.cs
public Form1()
{
InitializeComponent();
this.InitializePivotGrid();
}
private void InitializePivotGrid()
{
// Adding ItemSource to the Control
this.pivotGridControl1.ItemSource = ProductSalesData.GetSalesData();
// Adding PivotRows to the Control
this.pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName ="Product", TotalHeader = "Total" });
this.pivotGridControl1.PivotRows.Add(new PivotItem { FieldMappingName ="Date", TotalHeader = "Total" });
// Adding PivotColumns to the Control
this.pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "Country", TotalHeader = "Total" });
this.pivotGridControl1.PivotColumns.Add(new PivotItem { FieldMappingName = "State", TotalHeader = "Total" });
// Adding PivotCalculations to the Control
this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Amount", Format = "$ #,##0.00", SummaryType = SummaryType.DoubleTotalSum });
this.pivotGridControl1.PivotCalculations.Add(new PivotComputationInfo { FieldName = "Quantity", Format = "#,##0" });
this.pivotGridControl1.ShowGroupBar = true;
this.pivotGridControl1.TableControl.FilterArea.QueryCellInfo += FilterArea_QueryCellInfo;
}
private void FilterArea_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
if (e.RowIndex == 2 && e.ColIndex == 1)
{
e.Style.Text = "Drop fields here";
e.Style.TextColor = System.Drawing.Color.White;
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.