Understanding the Parameter Classes
The parameter object model is designed to give you complete control over almost every property of the parameter. The majority of the class properties have write access. This lets you modify parameters during runtime so that you can set the current value and the user isn’t prompted to enter it via the parameter dialog boxes. If you still want the user to use the parameter dialog boxes, you can modify the default values so that you have control over what values they choose from.
The object model uses three different collections to manage parameters. These collections are listed in Table 16-1. The ParameterFieldDefinitions collection manages the parameters in the ReportDocument class. The ParameterFields collection manages the parameters in the CrystalReportViewer class. A parameter can store one value or multiple values. Since a parameter can store multiple values, a collection is used to save this data. This collection is called the ParameterValues collection. It is shared between both ParameterFieldDefinitions and ParameterFields for storing CurrentValues and DefaultValues collections (both are a ParameterValues collection).
Table 16-1. The three types of parameter collections.
Collection | Purpose |
---|---|
ParameterFieldDefintions | Manages the parameters in the ReportDocument class. It is fully populated with all the parameters. Found in the CrystalDecisions.CrystalReports. Engine namespace. |
ParameterFields | Manages parameters in the CrystalReportViewer class. It is empty by default. Found in the CrystalDecisions.Shared namespace. |
ParameterValues | Manages the values stored within each parameter object. The ParameterFieldDefinitions collection and the ParameterFields collection both use this class. Found in the CrystalDecisions.Shared namespace. |
It’s important to know which namespace the collections are in. When writing an application, you will refer to these namespaces to access the collections. As an alternative, you can always use the Imports statement (using in C#) so that you don’t have to write out the full namespace name. The code samples in this chapter declare the full namespace so that you can learn them.