Create a Report in Visual Studio

  • 6 min to read

This document explains how to create a platform-independent report that you can print, save to a file, share, and reuse in different applications.

Create a new Visual Studio Project

The core Reporting functionality does not depend on the application platform. You can create any application with an active DevExpress subscription.

WinForms
  1. Press CTRL+SHIFT+N, or select FILE | New | Project... in the main menu.

create-new-application-windows-forms

  1. In the New Project dialog, expand the Installed category and select a programming language (Visual C# or Visual Basic) in the Templates section. Switch to the Windows section and select Windows Forms Application.

    Specify the application name and click OK.

WPF
  1. Press CTRL+SHIFT+N, or select FILE | New | Project... in the main menu.

create-new-application-windows-forms

  1. In the New Project dialog, expand the Installed category and select a programming language (Visual C# or Visual Basic) in the Templates section. Switch to the Windows Desktop section and select WPF Application.

    Specify the application name and click OK.

ASP.NET MVC
  1. Select FILE | New | Project… in the main menu or press CTRL+SHIFT+N.

create-new-application-windows-forms

  1. In the invoked New Project dialog, expand the Installed category, select a programming language (Visual C# or Visual Basic) in the Templates section, and select the DevExpress v19.2 Template Gallery.

    Specify the application name and click OK.

  2. In the invoked DevExpress Template Gallery, select Web Application With Selectable Layout under the ASP.NET MVC category and click Run Wizard.
TIP

You can also select Reporting Web Application to create an application that contains the HTML5 Document Viewer and/or Report Designer controls. See the following documents for instructions:

  1. On the DevExpress ASP.NET MVC Project Wizard Choose Layout page, select the application layout (Standard).

asp-net-devexpress-project-wizard-create-standard

  1. Switch to the Suites page, enable the Report suite, and click Create Project.

    asp-net-mvc-devexpress-project-wizard-suite

ASP.NET Web Forms
  1. Start Microsoft Visual Studio and press CTRL+SHIFT+N or click FILE | New | Project... in the main menu.

    create-new-application-windows-forms

You can also choose the Web Site option instead of Project. However, the Web Application project provides greater extensibility and easier support.

  1. In the New Project dialog, expand the Installed category, select a programming language (Visual C# or Visual Basic) in the Templates section, and select ASP.NET Web Application. Specify the application name and click OK.

  2. Choose Web Forms and click OK to create the project.

ASP.NET Core

Perform the following steps to create a new ASP.NET Core Web Application in Visual Studio:

  1. Create a new project (select File | New | Project in the main menu or press CTRL+SHIFT+N).

    create-new-project-vs2017

  2. Select the Installed | Visual C# | Web | ASP.NET Core Web Application project template in the invoked New Project dialog. Specify the application name and click OK.

    new-project-dialog-asp-net-core-application

  3. Select .NET Core in the top-left drop-down box. Then, select ASP.NET Core 2.1 in the version selector drop-down list. Choose Web Application (Model-View-Controller) and click OK.

    asp-net-core-application-settings

Add a New Report

The steps in this section are similar for different application platforms.

  1. In Visual Studio, press CTRL+SHIFT+A or select PROJECT | Add New Item... in the main menu.

    add-new-item-windows-forms

    If your project is ASP.NET Web Site

    Create the App_Code folder and select that folder to add a new item.

  2. In the invoked Add New Item dialog, click the Reporting section in the tree on the left, select the DevExpress v19.2 Report item, specify the report name (the default name is XtraReport1), and click Add.

  3. Select the report type in the invoked Report Wizard.

Select a Report Type

At this stage, choose a report type.

  • Blank report allows you to design a report from scratch.
  • Table Report allows you to create a data-bound report.
Report Types

The Report Wizard offers seven report type options.

  • Blank. Choose this template to open the Report Designer and create a report layout.

    getting-started-blank-report

  • Table Report. This template displays your data in a tabular format. get-started-add-table-report-result-design

  • Cross-Tab Report. Displays summarized data at row and column intersections. It is similar to a pivot table.

  • Vertical Report. A vertically-oriented Table Report: data fields are rows, data records are columns. This orientation is used for sources with a large number of data fields.

    VerticalBandDemoReport_WizardResult

  • Labels. Labels. Rectangular cards designed by AOne, APLI, Avery, Formtec, HERMA, Hisago, and others. You can use this template to print business cards, CD or video tape labels, wedding invitations, name badges, index cards, Rolodex cards, and other labels.

  • Template. Choose from invoice templates with different layout and appearance settings.

    get-started-template-wizard

  • Inherited Report. Allows you to build a new report that inherits its layout from an existing report. You can select a report from a list or load a .dll assembly/.exe file that contains the base report. get-started-inherited-report

Blank

Select Blank and click Finish.

The Report Designer displays the newly created blank report:

The next step:

  • Design a report. Review the Create a Report from A to Z for information on how to use report bands, add reporting controls and bind a report to data. Switch to the Preview tab to see your changes.

You can also choose Table Report and follow the steps in the next section.

Table Report

Select Table Report and click Next.

Follow the directions on the Wizard pages to create a data-bound report.

  1. This page allows you to select the data source type. Choose Database and click Next.

  2. On this page, specify whether to use an existing data connection from Visual Studio's Server Explorer or create a new connection.

    report-wizard-page-visual-studio-database-02a

    Select the first option and click Next.

  3. On this page, define a custom connection string or select one from the list of supported data providers.

    Depending on the data provider, specify additional connection options (such as authentication type and database name) on this page.

    For this example, bind a report to the sample Northwind database hosted on a Microsoft SQL Server.

    report-wizard-database-sql-server

    Click Next to proceed to the next wizard page.

  4. On this page, specify whether to save the connection string to the application's configuration file.

    report-wizard-save-connection-string

    If you choose to save the connection string, specify its name and click Next.

  5. On this page, choose which tables, views, and/or stored procedures to add to the report.

    Select the Products data table and click Next.

    get-started-simple-report-wizard-select-table

  6. On this page, select a data member in the left pane. Use the right pane to select the fields that should be displayed in the report.

    get-started-simple-report-wizard-select-fields

    Click Finish.

    NOTE

    You can click Next to proceed to the next wizard page and continue report customization.

  7. The Wizard creates a report and loads it in the designer. The report layout is shown below:

    get-started-add-table-report-result-design

Preview a Report

The Visual Studio Report Designer allows you to preview the report while working on it. Click the Preview tab to load data, create a document, and display it. If you follow the steps above to create a table report, the Preview looks like this:

When the report design is finished, you can perform the following tasks:

See Also