Pivot Grid for WinForms - How to Connect the Pivot Grid to an OLAP Data Source at Runtime
This example demonstrates how to add connection settings to the Adventure Works cube on the OLAP server.
To bind the Pivot Grid control to an OLAP cube, follow the steps below.
- Set the PivotGridControl.OLAPDataProvider property to ADOMD.
- Specify connection settings in the PivotGridControl.OLAPConnectionString property. The following connection string is used in this example:
Note that a valid connection string should include the following parameters: Provider, Data Source, Initial Catalog, and Cube Name.
OlapConnectionString="Provider=MSOLAP;Data Source=http://demos.devexpress.com/Services/OLAP/msmdpump.dll; + "Initial catalog=Adventure Works DW Standard Edition;Cube name=Adventure Works;Query Timeout=100;"
You can create Pivot Grid fields and bind them to measures and dimensions in the OLAP cube in the following ways:
Call the PivotGridControl.RetrieveFields method to create Pivot Grid fields for all columns in a data source and add them to the field's collection. Use the PivotGridControl.GetFieldList method to obtain a list of fields available in a bound data source.
Create a PivotGridField object and add it to the PivotGridControl.Fields collection. Then, use DataSourceColumnBinding and OLAPExpressionBinding to bind the field to data.
Specify the value of the PivotGridFieldBase.Name property for each field when you create Pivot Grid fields. You can use this value to determine fields in a stored layout.
Use the following properties to specify field location and visibility:
Use the invoked Customization Form to arrange fields.