Skip to main content
Tag

PivotGridField.Caption Property

Gets or sets the field’s display caption. This is a dependency property.

Namespace: DevExpress.Xpf.PivotGrid

Assembly: DevExpress.Xpf.PivotGrid.v23.2.dll

NuGet Package: DevExpress.Wpf.PivotGrid

Declaration

public string Caption { get; set; }

Property Value

Type Description
String

A string specifying the field’s display caption.

Remarks

Use the Caption property to specify the text displayed within the field’s header.

If the Caption property is set to an empty string the field’s header will display the value of the PivotGridField.FieldName property. If the PivotGridField.FieldName property is set to an empty string, the field’s header will display the value of the field’s Name property.

If the PivotGridField.ShowSummaryTypeName property is enabled, the field’s summary type enclosed in round brackets is appended to the field’s Caption.

Example

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:

  1. A typed dataset is created from the database at design time.
  2. Instances of SalesPersonDataTable and SalesPersonTableAdapter objects are created.
  3. The PivotGridControl is bound to the SalesPersonDataTable instance via the PivotGridControl.DataSource property.
  4. 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 example.

<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 Name="pivotGridControl1" DataProcessingEngine="Optimized">
            <dxpg:PivotGridControl.Fields>
                <dxpg:PivotGridField Name="fieldCountry"  Area="RowArea">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Country"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldCustomer" Area="RowArea"
                                     Caption="Customer">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Sales Person"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldYear" Area="ColumnArea" Caption="Year" >
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="OrderDate" GroupInterval="DateYear"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldCategoryName" Area="ColumnArea" Caption="Product Category">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="CategoryName"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldProductName" Area="FilterArea" Caption="Product Name">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="ProductName"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
                <dxpg:PivotGridField Name="fieldExtendedPrice" Area="DataArea" CellFormat="c0">
                    <dxpg:PivotGridField.DataBinding>
                        <dxpg:DataSourceColumnBinding ColumnName="Extended Price"/>
                    </dxpg:PivotGridField.DataBinding>
                </dxpg:PivotGridField>
            </dxpg:PivotGridControl.Fields>
        </dxpg:PivotGridControl>
    </Grid>
</Window>

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

Note

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