$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Windows Forms PivotGrid Control
Create interactive user interface of Pivot table, build summarizations and highlight specific data
Home > WinForms UI Controls > User Manual > PivotGrid Data Source Property in C#

Populate PivotGrid with Data using DataSource Property in C#.NET

KetticPivotGrid WinForms control has the same feature as any other data control for Windows Forms. It allows the users to populate this control to a data source by using a DataSource property of the KetticPivotGrid control. To bind PivotGrid to an existing data source, we can customize the properties of PivotGrid control, DataSource property and DataMember property. This article will demonstrate how to populate PivotGrid with data by using DataSource property in C#.NET template projects.

C# for Binding PivotGrid to Data with DataSource Property

The C# code below shows the process of populating PivotGrid control with data by setting the DataSource property and DataMember property of the control. In addition, we shall add the desired descriptions to define the data structure being shown.

this.ketticPivotGrid1.RowGroupDescriptions.Add(new
DateTimeGroupDescription() { PropertyName = "OrderDate", Step =
DateTimeStep.Year, GroupComparer = new GroupNameComparer() });

this.ketticPivotGrid1.RowGroupDescriptions.Add(new
DateTimeGroupDescription() { PropertyName = "OrderDate", Step =
DateTimeStep.Month, GroupComparer = new GroupNameComparer() });

this.ketticPivotGrid1.ColumnGroupDescriptions.Add(new
PropertyGroupDescription() { PropertyName = "CustomerID", GroupComparer = new
GrandTotalComparer() });

this.ketticPivotGrid1.AggregateDescriptions.Add(new
PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction
= AggregateFunctions.Sum });

this.ketticPivotGrid1.AggregateDescriptions.Add(new
PropertyAggregateDescription() { PropertyName = "Freight", AggregateFunction
= AggregateFunctions.Average });

this.ketticPivotGrid1.FilterDescriptions.Add(new PropertyFilterDescription()
{ PropertyName = "CustomerCity", CustomName = "City" });

NwindDataSet dataset = new NwindDataSet();
SamplesCS.DataSources.NwindDataSetTableAdapters.OrdersTableAdapter adapter =
new SamplesCS.DataSources.NwindDataSetTableAdapters.OrdersTableAdapter();
adapter.Fill(dataset.Orders);

this.ketticPivotGrid1.DataSource = dataset;
this.ketticPivotGrid1.DataMember = "Orders";
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls