IList and IEnumerable Data Sources
- 2 minutes to read
The Data Source Configuration Wizard allows you to bind the PivotGridControl to any object that implements the IList or IEnumerable interfaces (to learn more about such objects, see Traditional Data Binding Methods). This topic guides you through the steps needed to do this.
Note
In this topic, the data class from the following example will be used: How to: Bind a Control to Data Created at Runtime.
Click the Data Source Wizard button placed on the PivotGridControl or use the corresponding command in the control’s smart tag.
In the invoked Data Source Configuration Wizard, select IList/IEnumerable…
… and click Next.
On the next page, select the required binding method.
- Direct Binding to Data Source - allows you to bind the PivotGridControl to an object directly.
- Binding via the BindingSource Component - allows you to bind the PivotGridControl to an object using the BindingSource component that simplifies design-time data binding. To learn more, see BindingSource Component Specifics.
Select Direct Binding to Data Source and click Next.
On the final page, you need to specify the name of the required data class.
Start typing the name of the data class.
Then, select the required class from the list of classes offered by the Data Source Configuration Wizard and click Finish.
The following code will be generated by the Data Source Configuration Wizard.
public Form1() { InitializeComponent(); // This line of code is generated by the Data Source Configuration Wizard pivotGridControl1.DataSource = new System.Collections.Generic.List<WinFormsPivot.Record>(); }
You can work now with the created data source at runtime. For instance, to retrieve fields from the connected data source, call the PivotGridControl.RetrieveFields method.