Reports for WinForms | ComponentOne
In This Topic
    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:

    1. Open the C1ReportDesigner. For more information on how to access the C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
    2. Create a new report or open an existing report. Once you have the report in the C1ReportDesigner, you can modify the report properties.
    3. Click the Close Print Preview button to begin editing the report.
    4. In the Fields group of the Design tab, click the Add Label button to add a field to your report.
    5. Click on your report where you want the field placed and drag to resize the field.
    6. Set the following properties for the field:
      • Field.Name = linesPerPage
      • Field.Text = 14
      • Field.Visible = False
    7. To control the number of detail lines per page, use script. Select Detail from the drop-down list above the Properties window.
    8. Locate the OnPrint property and click the empty field next to it, and then click the ellipsis button.
      The VBScript Editor appears.
    9. 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.