For generating a Crystal Reports without database , here we are using a Strongly Typed Dataset and a Data Table.
Using the code
Create the Project:
- File -> New -> New project
Create a New Crystal Reports Visual Basic Windows Application.
Create the DataSet schema:
- Right click the Crystal Reports project -> Add -> New Folder
Name it DataSets:
- Right click the DataSets folder -> Add -> New Item
Create a new CRDataSet DataSet:
- Right click the CRDataSet Designer Page -> Add -> New Element
Name it MainTable:
- Add new Field1, Field2, Field3 rows.
- Repeat steps 3 and 4, add a new DetailTable element.
You will have the following DataSet tables schema:
Image may be NSFW.
Clik here to view.
Create the Crystal Reports report:
- Right click the Crystal Reports project -> Add -> New Folder
Name it Reports:
- Right click the Reports folder -> Add -> New Item
Open a new MainReport Crystal Reports report:
- Click the Register Later button to close the annoying register window, if it appears.
- Select Subreport and click OK. In the Contain Subeport Expert window Data tab, expand Project Data -> ADO.NET DataSet -> CrystalReport.CRDataSet.
- Select MainTable. Click the Insert Table button.
- Click Next.
- Click the Add All button. Click Next. Click Next. Click Next.
- Next to the Create a Subreport choice of the Subreport window tab, type DetailReport in the Report Nameedit box.
- Click the Report Expert button. Insert DetailTable. Click Next to open the Subreport Generator.
- Add All fields. Click Next. Click Next. Click Next. Click Next.
- Type “No DB Subreport Crystal Report Sample” as the Subreport Title.
- Click Finish.
Click Next. Type “No DB Crystal Report Sample.” as the Main Report title. Click Finish.
Image may be NSFW.
Clik here to view.
Add the a CrystalReportViewer1 to the form:
- Open the Form1 form. Click View -> Toolbox in the menu.
- Drag (from the bottom of the Windows Forms tab in the Toolbox) a CrystalReportViewer into the form.
- Right click the CrystalReportViewer1 CrystalReportViewer in the form -> Properties.
- Set the Dock property to Fill.
Add the code to fill and show the Crystal Reports report:
Right click the Form -> View Code. Add the following Form1_Activated method:
Image may be NSFW.
Clik here to view.
Add the following FillDataSet method:
Image may be NSFW.
Clik here to view.
Build and run the application.