Back to Devexpress

Tutorial 1 - Add the Pivot Grid and Bind It to Data

windowsforms-12005-controls-and-libraries-pivot-grid-getting-started-pivot-grid-walkthroughs-tutorial-1-bind-a-pivot-grid-to-an-mdb-database.md

latest5.2 KB
Original Source

Tutorial 1 - Add the Pivot Grid and Bind It to Data

  • Sep 16, 2022
  • 3 minutes to read

The following tutorial explains how to add the Pivot Grid to a WinForms application and connect the control to the Northwind SQLite Database.

Prerequisites

Create a New Project and Add a Pivot Grid

Run Microsoft Visual Studio and create a new Windows Forms App (.NET Framework) project.

Specify the project’s name and location in the New Project wizard.

Drag the PivotGridControl item from the DX.25.2: Data & Analytics toolbox group onto the form.

Open the Pivot Grid’s smart tag menu and click Dock in Parent Container to let the Pivot Grid fill the entire window’s client area.

Add the Database to the Project

Add the Northwind Database to the project. For example, create the “Data” folder in your project and place the nwind.db file in the folder.

Install the System.Data.SQLite NuGet Package

In the Visual Studio menu, click Tools - NuGet Package Manager - Manage NuGet Packages for a Solution. In the invoked window, select the System.Data.SQLite package and click Install.

Connect the Pivot Grid to the Database in the Data Source Wizard

Click the Data Source Wizard panel.

In the invoked wizard, select SQL Data Connection and click New Data Source….

Click OK to create a new data source.

Configure the data connection

On the next page, select “No, I’d like to specify the connection parameters myself” to create a new data connection. Click Next.

Specify connection parameters. Choose SQLite as a data provider and specify a path to the Northwind database. Click Next to continue.

Click Next on the next page to save the connection string to the configuration file.

Specify a Query

Click Run Query Builder… to invoke the Query Builder dialog.

Drag the SalesPerson table and drop it on the diagram pane. Select the following table fields to include them in the query:

  • ProductName
  • CategoryName
  • OrderDate
  • ExtendedPrice

Click OK. The resulting query is displayed in the wizard.

Click Finish to create the data source.

Result

As a result, Visual Studio generates an SqlDataSource instance that supplies data from the Northwind database to the Pivot Grid control.

The sqlDataSource1 component is an SqlDataSource instance (a collection of tables, relationships, and constraints) that contains tables from the Northwind database.

The following help topic contains information about the functionality used in the tutorial: Bind to Data.

Next Step

In the next tutorial, you create Pivot Grid fields, populate them with data, and configure the Pivot Grid layout.

Tutorial 2 - Populate Pivot Grid Fields with Data and Configure Layout