Skip to main content

PivotGridControl.Fields Property

Provides access to a PivotGrid control’s field collection.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v23.2.dll

NuGet Package: DevExpress.Win.PivotGrid


[XtraSerializableProperty(XtraSerializationVisibility.Collection, true, true, true, 0, XtraSerializationFlags.DefaultValue)]
public PivotGridFieldCollection Fields { get; }

Property Value

Type Description

A PivotGridFieldCollection object which represents a collection of all the fields within a PivotGridControl.


This property stores all the fields present in the PivotGrid control. It allows you to add and delete fields using the appropriate methods.

Individual fields can be accessed using indexed notation or the bound field name as parameters. If the bound field name is used as an indexer and there are several fields with the same name (for example, the GroupInterval feature is used), the first field found in the collection will be returned.


This example demonstrates how to create the Pivot Grid fields in code and specify their location and format. The Pivot Grid’s data source is the ExcelDataSource instance, created in code.


using DevExpress.DataAccess.Excel;
using DevExpress.XtraEditors;
using DevExpress.XtraPivotGrid;
using System;

namespace WinFormsPivotGridDataFieldsExample {
    public partial class Form1 : XtraForm {
        public Form1() {
            this.Load += Form1_Load;
            // Create the Excel Data Source.
            ExcelDataSource ds = new ExcelDataSource();
            ds.FileName = "SalesPerson.xlsx";
            ExcelWorksheetSettings settings = new ExcelWorksheetSettings("Data");
            ds.SourceOptions = new ExcelSourceOptions(settings);
            // Set the pivot's data source.
            pivotGridControl1.DataSource = ds;
            // Create pivot grid fields.
            PivotGridField fieldCategoryName = new PivotGridField() {
                Area = PivotArea.RowArea,
                AreaIndex = 0,
                Caption = "Category Name"
            // Bind fields to columns in the data source.
            DataSourceColumnBinding categoryNameBinding = new DataSourceColumnBinding("CategoryName");
            fieldCategoryName.DataBinding = categoryNameBinding;    

            PivotGridField fieldProductName = new PivotGridField() {
                Area = PivotArea.RowArea,
                AreaIndex = 1,
                Caption = "Product Name"

            DataSourceColumnBinding productNameBinding = new DataSourceColumnBinding("ProductName");
            fieldProductName.DataBinding = productNameBinding;    

            PivotGridField fieldExtendedPrice = new PivotGridField() {
                Area = PivotArea.DataArea,
                AreaIndex = 0,
                Caption = "Extended Price"

            DataSourceColumnBinding extendedPriceBinding = new DataSourceColumnBinding("Extended Price");
            fieldExtendedPrice.DataBinding = extendedPriceBinding; 

            // Specify the field format.
            fieldExtendedPrice.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            fieldExtendedPrice.CellFormat.FormatString = "c2";

            PivotGridField fieldOrderDate1 = new PivotGridField() {
                Area = PivotArea.ColumnArea,
                AreaIndex = 0,
                Caption = "Year"

            DataSourceColumnBinding fieldOrderDate1Binding = new DataSourceColumnBinding("OrderDate");
            fieldOrderDate1Binding.GroupInterval = PivotGroupInterval.DateYear;
            fieldOrderDate1.DataBinding = fieldOrderDate1Binding; 

            PivotGridField fieldOrderDate2 = new PivotGridField() {
                Area = PivotArea.ColumnArea,
                AreaIndex = 1,
                Caption = "Quarter"

            DataSourceColumnBinding fieldOrderDate2Binding = new DataSourceColumnBinding("OrderDate");
            fieldOrderDate2Binding.GroupInterval = PivotGroupInterval.DateQuarter;
            fieldOrderDate2.DataBinding = fieldOrderDate2Binding; 

            PivotGridField fieldCountry = new PivotGridField() {
                AreaIndex = 0,
                Caption = "Country"

            DataSourceColumnBinding countryBinding = new DataSourceColumnBinding("Country");
            fieldCountry.DataBinding = countryBinding; 

            // Create a field's filter.
            fieldCountry.FilterValues.FilterType = PivotFilterType.Included;
            // Add fields to the pivot grid.
            pivotGridControl1.Fields.AddRange(new PivotGridField[] {

        private void Form1_Load(object sender, EventArgs e) {

The following code snippets (auto-collected from DevExpress Examples) contain references to the Fields property.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also