Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

14.11 CrystalReportViewer Object Model

CrystalReportViewer Object Model

Previewing reports is done with the CrystalReportViewer control. The viewer can be used as an alternative to the ReportDocument class for modifying reports during runtime. It is a lightweight control and only exposes a few properties. You can use it when you only need want to perform basic tasks.

The viewer exposes three properties for modifying a report. The RecordSelection property filters the report data. The ParameterFieldInfo property is the ParameterFields collection (discussed in Chapter 16). The LogOnInfo property (discussed in Chapter 17) is a collection of TableLogOnInfo objects for setting the user credentials for each table. These collections are already found in the ReportDocument class, but they are provided in this class in case you don’t need to work directly with the ReportDocument class.


Figure 14-3. The CrystalReportViewer object model.

I prefer making all runtime modifications using only the ReportDocument object and not the CrysalReportViewer control. It is by far the most robust of the two objects. By learning the ReportDocument properties andmethods, you don’t have to learn the viewer class. The only time you can’t perform modifications with the ReportDocument object is when you are writing Report Web Services. This requires using the viewer object to make runtime modifications.