Back to Devexpress

PivotGridControl.RetrieveFields() Method

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-7ae90f23.md

latest5.3 KB
Original Source

PivotGridControl.RetrieveFields() Method

Creates PivotGridField objects for all columns in the bound data source.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
public void RetrieveFields()
vb
Public Sub RetrieveFields

Remarks

This method clears the field collection and adds new PivotGridField objects to the collection for all columns in the control’s bound data source.

The RetrieveFields method generates DataSourceColumnBinding objects for each Pivot Grid field in OLAP, Server, and Optimized modes. The Pivot Grid fields obtain their values from columns in the data source. The DataSourceColumnBindingBase.ColumnName property is set to the name of the data source column. The created fields are made visible and displayed within the Filter Header Area.

Use the PivotGridControl.Fields property to add or remove fields. For instance, you can add a calculated field to a collection that contains arbitrary data in the Pivot Grid control. Refer to the following topic for more information about calculated fields: Bind Pivot Grid Fields to Calculated Expressions.

Use the PivotGridControl.RetrieveFieldsAsync method to create fields asynchronously.

Specify a value of the PivotGridFieldBase.Name property for each field when you create Pivot Grid fields. The value can be used to determine fields in a stored layout. For example, the following code snippet sets field names for all fields in the Pivot Grid:

csharp
pivotGridControl1.RetrieveFields();
foreach(PivotGridField field in pivotGridControl1.Fields)
field.Name = "field" + (field.DataBinding as DataSourceColumnBinding).ColumnName;
vb
pivotGridControl1.RetrieveFields()
For Each field As PivotGridField In pivotGridControl1.Fields
field.Name = "field" & (TryCast(field.DataBinding, DataSourceColumnBinding)).ColumnName
Next field

Refer to the following topic for more information about Pivot Grid Fields: Pivot Grid Fields.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the RetrieveFields() method.

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.

winforms-pivot-grid-draw-a-custom-element-on-mouse-hover/CS/WindowsApplication73/Form1.cs#L24

csharp
pivotGridControl1.DataSource = CreateTable(500);
pivotGridControl1.RetrieveFields();
pivotGridControl1.Fields["Order"].Area = PivotArea.RowArea;

winforms-pivot-grid-draw-a-custom-element-on-mouse-hover/VB/WindowsApplication73/Form1.vb#L21

vb
pivotGridControl1.DataSource = CreateTable(500)
pivotGridControl1.RetrieveFields()
pivotGridControl1.Fields("Order").Area = PivotArea.RowArea

See Also

DataSource

DataMember

Fields

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace