Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

1.02 Windows Form Preview

Previewing with a Windows Form

After creating the Employee List report in the previous section, you can preview it using either a Windows Form or an ASP.NET application. This section shows you how to preview it from a Windows Form. Previewing it with ASP.NET is covered in the following section.

Previewing the report requires modifying an existing form. When you created the new project, Form1 should have been automatically added to the project for you. Open Form1 in design mode and add a CrystalReportViewer control to it. This is normally listed in the Reporting section near the bottom of the Toolbox. Resize the viewer so that it fills up the entire form. Do this by finding its Dock property and clicking on the drop-down box. Click on the middle square so that the property is set to Fill.

The viewer control has many ways to preview reports. This example uses the Smart Tasks button to add a new report to the viewer control. If you click on the viewer control, you’ll see a small arrow in the top right corner. This is shown in Figure 1-6.



Figure 1-6. The ReportDocument dialog box.

Click on it to get a list of the Tasks available. Select the task Choose a Crystal Report. In the next dialog box, select the Employee List report and click the OK button. This adds the ReportDocument component to your form.

The viewer immediately shows you a preview of the report. You don’t have to run the application to see how it will look. However, the viewer buttons have no functionality until you run the application. Go ahead and run the report. Form1 will open and show you the report. You can click on the buttons on the toolbar and test out some of its functionality. The preview of the Employee List report is shown in Figure 1-6.



Figure 1-7. Employee List report output in preview mode.

You can see that this quick report isn’t perfect and could use better formatting. As is usually the case, the report expert gives you a good basis for writing a report, but you still need to make some changes to clean it up.