Adding Crystal Reports to Projects
A report added to a Visual Basic or C# project is a "strongly-typed" report. A report source file, containing a report class specific to this report, is automatically created for it. This report class has
ReportClass as its base class. For more information on the
ReportClass class, please refer to the derived class ReportDocument.
The report source file also shows sections of the Crystal report. These sections should not be modified.
The report source file has the extension .cs for a Visual C# project, and .vb for a Visual Basic project. This file is normally hidden. You can click the Show All Files icon to list it (e.g., under CrystalReport1.rpt) in the Solution Explorer.
Note Unlike reports added to Visual Basic or C# projects, no report class or report source file is automatically created for reports added to C++ projects. You can add code to create the corresponding report classes for these reports.
To add a new Crystal report to a project
- In the Solution Explorer, right-click the project name, point to Add and select Add New Item from the shortcut menu. (Alternatively, highlight the project name in the Solution Explorer; from the Project menu in the Visual Studio Standard Toolbar, select Add New Item.)
- In the Add New Item dialog box, select Crystal Report from the Templates pane.
Alternatively, expand the folder tree in the Categories pane, highlight Utility, and select Crystal Report from the Templates pane.
- Enter a report name with an .rpt extension in the Name field. Or, accept the default report file name, CrystalReport1.rpt, if it exists.
- Click Open to invoke the Crystal Report Designer that helps you create and design the new report.
To add an existing Crystal report to a project
- In the Solution Explorer, right-click the project name and point to Add and select Add Existing Item from the shortcut menu.
- In the Add Existing Item dialog box, select All Files under Files of type. Specify the location and name of the report you are adding.