Represents a pivot grid field.
public class PivotGridField : DXFrameworkContentElement, ILogicalOwner, IInputElement, IThreadSafeField
Public Class PivotGridField Inherits DXFrameworkContentElement Implements ILogicalOwner, IInputElement, IThreadSafeField
Related API Members
The following members accept/return PivotGridField objects:
Pivot grid fields represent data source fields. Fields are visually represented by field headers, which can be moved between the pivot grid's areas using drag-and-drop. Dragging fields between areas modifies the report's layout.
The collection of fields can be accessed via the PivotGridControl.Fields property. Individual fields are represented by the PivotGridField class and can be accessed using indexed notation.
To learn more on pivot grid fields, see:
The following example demonstrates how to bind the PivotGridControl to a "SalesPerson" view in the nwind.mdb database, which is shipped with the installation. The control will be used to analyse sales per country, customers, product categories and years.
The following steps were used to created this example:
- A typed dataset is created from the database at design time.
- Instances of SalesPersonDataTable and SalesPersonTableAdapter objects are created.
- The PivotGridControl is bound to the SalesPersonDataTable instance via the PivotGridControl.DataSource property.
- The table is filled with data in the Window_Loaded event handler.
The pivot grid fields that will represent data source fields are created in XAML markup. They are positioned within appropriate areas to analyze the data in the way you want.
Note that if you want to see an example of how to programmatically add pivot grid fields, please refer to the How to: Bind a PivotGrid to an MS Access Database Programmatically tutorial.
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-bind-a-pivotgrid-to-an-ms-access-database-e2121.
<Window x:Class="HowToBindToMDB.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxpg="http://schemas.devexpress.com/winfx/2008/xaml/pivotgrid" Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"> <Grid> <dxpg:PivotGridControl HorizontalAlignment="Left" Name="pivotGridControl1" VerticalAlignment="Top"> <dxpg:PivotGridControl.Fields> <dxpg:PivotGridField Name="fieldCountry" FieldName="Country" Area="RowArea" /> <dxpg:PivotGridField Name="fieldCustomer" FieldName="Sales Person" Area="RowArea" Caption="Customer" /> <dxpg:PivotGridField Name="fieldYear" FieldName="OrderDate" Area="ColumnArea" Caption="Year" GroupInterval="DateYear" /> <dxpg:PivotGridField Name="fieldCategoryName" FieldName="CategoryName" Area="ColumnArea" Caption="Product Category" /> <dxpg:PivotGridField Name="fieldProductName" FieldName="ProductName" Area="FilterArea" Caption="Product Name" /> <dxpg:PivotGridField Name="fieldExtendedPrice" FieldName="Extended Price" Area="DataArea" CellFormat="c0" /> </dxpg:PivotGridControl.Fields> </dxpg:PivotGridControl> </Grid> </Window>