Setting the Report Options
The ReportOptions class only has a few properties that can be set. They are listed in Table 14-2. This information is set during design mode by right-clicking on the report and selecting Designer | Default Settings and selecting the Reporting tab. These properties were discussed in Chapter 2.
Table 14-2. Properties of the ReportOptions class.
Property | Description |
---|---|
EnableSaveDataWithReport | Saves the latest data with the report. Allows report to be opened without a live data connection. |
EnableSavePreviewPicture | Saves a thumbnail picture of the report. |
EnableSaveSummariesWithReport | Saves data summaries with the report. |
The following example sets the EnableSaveDataWithReport property to True.
Dim MyReport As New CrystalReport1
MyReport.ReportOptions.EnableSaveDataWithReport = True
Connecting to the Data Sources
The Database class is used for examining the tables used in a report and their relationships with each other. It’s also used for setting the login information before opening the report. This class is described in Chapter 17.
Modifying the Printing Options
The PrintOptions class stores the options for how a report is sent to the printer. This can consist of the destination printer, the paper orientation or the page margins. This is normally set during design mode. While the majority of an application’s reports will use the same settings, you can override the default settings for specific reports. Table 14-3 lists the properties.
Table 14-3. PrintOptions properties.
Property | Description |
---|---|
PageMargins | Gets the page margins. |
ApplyPageMargins() | Sets new page margins. |
PaperOrientation | Switch between Landscape and Portrait. |
PaperSize | Set the paper size using pre-defined size constants. |
PaperSource | Set the tray that the paper is printed from. |
PrinterName | Change the printer by passing a string that exactly matches the printer name listed in the Printers Control Panel. |
Each of these properties is easy to modify. In same cases you will have to use a predefined constant to set the property (e.g. PaperOrientation and PaperSize).
Dim MyReport As New CrystalReport1
MyReport.PrintOptions.PaperOrientation = CrystalDecisions.[Shared].PaperOrientation.Landscape
MyReport.PrintOptions.PrinterName = "HP LaserJet510"
MyReport.PrintToPrinter(1, False, 0, 0)