Skip to main content

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

  • 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.

Create Windows Forms App

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

Configure Windows Forms App

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

GettingStarted_L1_Toolbox

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.

GettingStarted_L1_Dock

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.

Install Microsoft.Data.Sqlite package

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

Click the Data Source Wizard panel.

Data Source Wizard panel

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

Create a new SQL data source

Click OK to create a new data source.

GettingStarted_L1_MessageBox

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.

Configure data connection

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

Specify connection parameters

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

Save the connection string

Specify a Query

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

Invoke Query Builder

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

Specify a query in the Query Builder

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

Resulting query

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.

GettingStarted_L1_Result

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