ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Reports for WinForms Task-Based Help > Reporting Task-Based Help > Customizing the Page Headers > Changing Page Headers Dynamically

Changing Page Headers Dynamically

To specify whether Page Header and Page Footer sections should appear on all pages, or be suppressed on the pages that contain the report Header and report Footer sections use C1Reports PageHeader and PageFooter properties.

Sometimes you may want to further customize this behavior. For example, you may want to render different headers on odd and even pages. This can be done with some script that shows or hides fields depending on the page being rendered. 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 Design mode, select Detail from the drop-down list above the Properties window.

5.   Locate the OnFormat property and click the empty field next to it, and then click the ellipsis button.

6.   The VBScript Editor appears. Enter the following VBScript expression in the code editor:

odd = (page mod 2 <> 0)

h1odd.Visible = odd

h2odd.Visible = odd

h1even.Visible = not odd

h2even.Visible = not odd

This script will show or hide fields for odd and even pages if a report header contains several fields named "h<x>odd" and "h<x>even".

Note that to prevent the page header from showing blank spaces, all the fields should have the CanShrink property set to True.

* Sample Report Available

For the complete report, see report "09: Dynamic Page Header" in the CommonTasks.xml report definition file, which is available for download from the CommonTasks sample on the ComponentOne HelpCentral Sample page.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.