Binding FlexPivot to Data Source in Code
In This Topic
You can also bind the FlexPivot controls to a data source kept locally at your machine in code. Follow the given steps to bind the FlexPivotPage control to data source (c1nwind.mdb) in code.
In Code
- Create a Windows Forms Application project in Visual Studio.
- Drag-and-drop FlexPivotPage control to the Form.
- Switch to the code view and add the following code to initialize a standard connection string.
This code creates a connection with the c1nwind.mdb database file installed on your system at Documents\ComponentOne Samples\Common location on your system.
- Add the following code in the Form's constructor to fetch data from the data source through Oledb adapters.
- Bind the FlexPivotPage control to the data source using DataSource property of FlexPivotPage class in the Form's constructor.
- Press F5 to run the application. FlexPivotPage is now connected to the c1nwind.mdb file with various data fields available in the FlexPivotPanel.
You can now create different views by dragging the data fields to Rows, Columns and Values list for data analysis.