windowsforms-404010-controls-and-libraries-pivot-grid-binding-to-data-olap-mode-bind-pivot-grid-fields-to-data-columns.md
This topic describes how to use the Binding API to bind a Pivot Grid field to a measure or dimension in OLAP mode.
Follow the steps below to bind a Pivot Grid field to a measure or dimension:
Add a new data field in any of the following ways:
Set the field’s PivotGridFieldBase.DataBinding property to Data Source Column.
Specify the source column in the DataSourceColumnBindingBase.ColumnName property.
Follow the steps below to bind a Pivot Grid’s field to a measure or dimension in code in OLAP mode:
Create a DataSourceColumnBinding instance.
Specify the DataSourceColumnBindingBase.ColumnName property. ColumnName must specify the full name of the bound measure or dimension.
Assign the DataSourceColumnBinding object to the PivotGridFieldBase.DataBinding property.
The following code snippet illustrates how to create the fieldCity field and bind it to the City dimension:
PivotGridField fieldCity = pivotGridControl1.Fields.Add("City", PivotArea.RowArea);
fieldCity.DataBinding = new DataSourceColumnBinding("[Customer].[City].[City]");
fieldCity.Name = "fieldCity";
Dim fieldCity As PivotGridField = pivotGridControl1.Fields.Add("City", PivotArea.RowArea)
fieldCity.DataBinding = New DataSourceColumnBinding("[Customer].[City].[City]")
fieldCity.Name = "fieldCity"
View Example: How to Connect a Pivot Grid to an OLAP Data Source