Share via


Adding a CrystalReportViewer Control in Visual Studio

To display reports on a Windows Form, you add a CrystalReportViewer control.

  1. Open Form1 in Design view.

  2. From the Toolbox, open the Reporting node to locate the CrystalReportViewer control.

    Note

    In previous versions of Crystal Reports for Visual Studio, the CrystalReportViewer control appeared in the Crystal Reports node.

  3. Drag and drop the CrystalReportViewer control onto the form.

The CrystalReportViewer control displays a new GUI feature known as a Smart Task panel on the upper-right corner of the control.


> [!NOTE]
> <P>This is part of the reduced-code development model provided with .NET version 2.0. The Smart Task panel for the CrystalReportViewer control simplifies configuration of functionality such as report binding and control layout using GUI settings. Since you are currently working with the code-based development model, the Smart Task panel is not used during this setup. To learn more about the Smart Task panel, see <A href="ms225481(v=vs.90).md">Smart Tasks</A>.</P>
  1. If the Smart Task panel is open, click the arrow toggle on the upper-right corner of the CrystalReportViewer control to close the Smart Task panel.

  2. Click the CrystalReportViewer control to select it.

  3. From the Properties window, set the Name property:

    • For Visual Basic Windows project, set the Name property to myCrystalReportViewer.
    • For C# Windows project, set the Name property to crystalReportViewer.
  4. From the File menu, click Save All.

  5. From the Build menu, click Build Solution.

To add Imports/Using Statements to reference namespaces

  1. If the References folder is not visible in Solution Explorer, on the Solution Explorer toolbar, click Show All Files to display all project files.

  2. In Solution Explorer, expand the References folder.

  3. Verify that the following Crystal Reports assemblies have been added:

    • CrystalDecisions.CrystalReports.Engine
    • CrystalDecisions.Shared
  4. Select Form1, and then from the View menu, click Code.

  5. Above the class signature, add an "Imports" [Visual Basic] or "using" [C#] declaration to the top of the class containing the following Crystal Reports namespaces.

    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    

You have now completed Project Setup. However, a number of tutorials have additional setup requirements, such as adding a sample report. Continue to Additional Setup Requirements.