Reports for WPF | ComponentOne
Task Based Help / Customize Page Header / Dynamically changing of Page Header
In This Topic
    Dynamically changing of Page Header
    In This Topic

    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 C1.C1Report.C1Report's C1.C1Report.Layout.PageHeader and C1.C1Report.Layout.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 script that shows or hides fields depending on the page being rendered. To do this, complete the following steps:

    1. Open the C1ReportDesigner application. For more information on how to access C1ReportDesigner, see Accessing C1ReportDesigner from Visual Studio.
    2. Create a new report|tag=Creating a Basic Report Definition or open an existing report. Once you have the report in the C1ReportDesigner application, 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 C1.C1Report.Section.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 C1.C1Report.Field.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.

    See Also