The following example demonstrates how to bind the Pivot Grid control to a SalesPerson
view in the nwind.mdb database included with the installation.
Follow the steps below to connect the Pivot Grid to a database.
- Create an
OleDbConnection
object and specify the connection string in its constructor. - Create an
OleDbDataAdapter
instance to select records from the data source. - Create a new
DataSet
object and populate it with data. - Use the PivotGridControl.DataSource property to assign the resulting data source to the Pivot Grid.
Follow the steps below to create and configure Pivot Grid fields.
- Create a PivotGridField object and add it to the PivotGridControl.Fields collection.
- Specify the field’s area and position within this area. For this, use the PivotGridFieldBase.Area and PivotGridField.AreaIndex properties. AreaIndex can be set only after the field is added to the control’s field collection.
- Create a DataSourceColumnBinding object for each field.
- Set the DataSourceColumnBindingBase.ColumnName property to the name of the column in the data source. The Pivot Grid fields obtain their values from columns in the data source.
- Assign the
DataSourceColumnBinding
object to the field’s PivotGridFieldBase.DataBinding property.
(you will be redirected to DevExpress.com to submit your response)