Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.05 Previewing Reports with the CrystalReportViewer

Windows Development

Each of the integration options presented in the previous section have a specific way that they must be implemented to work properly. This section discusses the details of each option and walks you through the steps to implement them in a Windows application.

Previewing Reports with the CrystalReportViewer

Most applications give the user the ability to preview a report before printing it. With Crystal Reports, this is controlled by the CrystalReportViewer control. In fact, using the viewer is the only way to preview a report in your application. The viewer is found in the Toolbox at the bottom of the other components. Double-click on it to add it to your form.



Figure 3-1. The CrystalReportViewer previewing a report.

Figure 3-1 shows the viewer previewing a report. Along the top of the viewer is a toolbar with a variety of navigational buttons. In the center is the report preview window with a Group Tree window to the left of it. Along the bottom is a status bar that shows the page number information and the current zoom factor.

By default, the toolbar buttons and Group Tree window are all enabled. Each of these features has a corresponding property that can be set in design mode and during runtime so that can turn them on or off. For example, a report that doesn’t have any groups certainly doesn’t need to show the Grouping Tree window. You may also want to turn off all these features so that you can create a customized preview form using your own buttons. Having a customized preview form lets you control the user interface by using your own style of buttons. This insures that your application has a consistent look and feel across all forms.

The status bar can’t be modified. There are no properties to turn it on or off. Nor are there any properties to control what it displays. You can work around this limitation by extending the bottom of the viewer below the edge of the form or panel it is located in. This results in hiding the status bar.

Table 3-3 lists the properties of the CrystalReportViewer. The properties let you enable or disable the features of the viewer. Table 3-4 lists its methods. The methods let you implement the viewer’s functionality by calling them from your own buttons. Most of these are self-explanatory, but the tables make good reference material.