# Bind Pivot Grid Fields to Data Columns | WinForms Controls | DevExpress Documentation

This topic describes how to use the [Binding API](/CoreLibraries/401533/devexpress-pivot-grid-core-library/data-binding-api) to bind a Pivot Grid field to a data source column when the Pivot Grid uses the Optimized data processing engine.

## Design-Time

Follow the steps below to bind a Pivot Grid field to a data source column:

1. Add a new data field in any of the following ways:

    - Click ‘Run Designer’ in the PivotGrid’s smart tag menu. In the [Pivot Grid Designer](/WindowsForms/1825/controls-and-libraries/pivot-grid/design-time-features/pivotgrid-designer) window, select the [Fields](/WindowsForms/1826/controls-and-libraries/pivot-grid/design-time-features/pivotgrid-designer/fields-page) page and click ![AddNewFieldButton](/WindowsForms/images/addnewfieldbutton21412.png) or ![InsertNewFieldButton](/WindowsForms/images/insertnewfieldbutton21413.png) to add a new field.
    - Use one of the ‘Add Field to…’ options in the PivotGrid’s smart tag menu to add a new field to the required area directly. Then, you can specify its properties in the property grid or in the field’s smart tag menu.
2. Set the field’s [PivotGridFieldBase.DataBinding](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridFieldBase.DataBinding) property to `Data Source Column`.
3. Specify the source column in the [DataSourceColumnBindingBase.ColumnName](/CoreLibraries/DevExpress.PivotGrid.DataBinding.DataSourceColumnBindingBase.ColumnName) property. For example, the image below illustrates a Pivot Grid field that is bound to the Extended Price column:

     ![Bind a Pivot Grid Field to a Column](/WindowsForms/images/pivot-grid-data-source-column-binding.png)

## Runtime

Follow the steps below to bind a Pivot Grid’s field to the data source field in code:

1. Create a [DataSourceColumnBinding](/WindowsForms/DevExpress.XtraPivotGrid.DataSourceColumnBinding) instance.
2. Set the [DataSourceColumnBindingBase.ColumnName](/CoreLibraries/DevExpress.PivotGrid.DataBinding.DataSourceColumnBindingBase.ColumnName) property to the name of the source data field.
3. Assign the `DataSourceColumnBinding` object to the [PivotGridFieldBase.DataBinding](/CoreLibraries/DevExpress.XtraPivotGrid.PivotGridFieldBase.DataBinding) property.

The following code snippet illustrates how to create the Pivot Grid’s `fieldProductAmount` field and bind it to the `ProductAmount` source field:

- C#
- VB.NET

<section id="tabpanel_LpPEKSjDN9_tabid-csharp" role="tabpanel" data-tab="tabid-csharp">
<pre><code class="lang-csharp">PivotGridField fieldProductAmount = new PivotGridField() {
    Area = PivotArea.DataArea,
    Caption = &quot;Product Sales&quot;,
    Name = &quot;fProductAmount&quot;
};

DataSourceColumnBinding productAmountBinding = new DataSourceColumnBinding(&quot;ProductAmount&quot;);
//Bind a field to a column in the data source.
fieldProductAmount.DataBinding = productAmountBinding;
pivotGridControl.Fields.Add(fieldProductAmount);
</code></pre></section>
<section id="tabpanel_LpPEKSjDN9_tabid-vb" role="tabpanel" data-tab="tabid-vb" aria-hidden="true" hidden="hidden">
<pre><code class="lang-vb">Dim fieldProductAmount As New PivotGridField()
fieldProductAmount.Area = PivotArea.DataArea
fieldProductAmount.Caption = &quot;Product Sales&quot;
fieldProductAmount.Name = &quot;fProductAmount&quot;

Dim productAmountBinding As New DataSourceColumnBinding(&quot;ProductAmount&quot;)
&#39;Bind a field to a column in the data source.
fieldProductAmount.DataBinding = productAmountBinding
pivotGridControl.Fields.Add(fieldProductAmount)
</code></pre></section>

[Run Demo: Optimized Mode - Field Calculation Bindings module in the XtraPivotGrid MainDemo](dxdemo://Win/XtraPivotGrid/MainDemo/CodeExamples/Optimized_Mode.Field_Calculation_Bindings)

See Also

[Bind Pivot Grid Fields to Calculated Expressions](/WindowsForms/1799/controls-and-libraries/pivot-grid/binding-to-data/in-memory-mode/Optimized-Mode/bind-pivot-grid-fields-to-calculated-expressions)

[PivotGridField](/WindowsForms/DevExpress.XtraPivotGrid.PivotGridField)

[Pivot Grid Data Processing Modes](/CoreLibraries/403802/devexpress-pivot-grid-core-library/pivot-grid-modes)

[Bind Pivot Grid Fields to Window Calculations](/WindowsForms/403904/controls-and-libraries/pivot-grid/binding-to-data/in-memory-mode/Optimized-Mode/bind-pivot-grid-fields-to-window-calculations)