Defining and Using Global Constants
In This Topic
There is no special mechanism for defining and using global constants in a report, but you can add hidden fields to the report and use their values as global parameters. To do this, complete the following steps:
- Open the C1ReportDesigner. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
- Create a new report or open an existing report. Once you have the report in the C1ReportDesigner, you can modify the report properties.
- Click the Close Print Preview button to begin editing the report.
- In the Fields group of the Design tab, click the Add Label button to add a field to your report.
- Click on your report where you want the field placed and drag to resize the field.
- Set the following properties for the field:
- Field.Name = linesPerPage
- Field.Text = 14
- Field.Visible = False
- To control the number of detail lines per page, use script. Select Detail from the drop-down list above the Properties window.
- Locate the OnPrint property and click the empty field next to it, and then click the ellipsis button.
The VBScript Editor appears.
- Enter the following VBScript expression in the code editor:
cnt = cnt + 1
detail.forcepagebreak = "none"
if cnt >= linesPerPage then
cnt = 0
detail.forcepagebreak = "after"
endif
Note that the value in the linesPerPage field can be set prior to rendering the report, by changing the field's Text property.
Note: For the complete report, see report "08: Global Constant" in the CommonTasks.xml report definition file, which is available in the ComponentOne Samples folder.