Reports for WPF | ComponentOne
Task Based Help / Loading a Report into the C1DocumentViewer Control
In This Topic
    Loading a Report into the C1DocumentViewer Control
    In This Topic

    To load a report into the C1DocumentViewer control, just set the C1DocumentViewer.FileName and C1DocumentViewer.ReportName properties. You can do so in the designer, in code or in XAML:

    In the Designer

    To load a report in the designer, complete the following steps:

    1. Select the C1DocumentViewer control and navigate to the Properties window.
    2. Select the ellipsis button next to the C1DocumentViewer.FileName property to open the Open dialog box.

    1. Locate and open a report definition file. For example, open the CommonTasks.xml file installed by default in the samples installation directory.

    The reports available in the reports file should now appear in the C1DocumentViewer.ReportName drop-down box.

    1. Click the C1DocumentViewer.ReportName drop-down box and select a report. For example, select 01: Alternating Background (Greenbar report).

    In Code

    Set theC1DocumentViewer.FileName and C1DocumentViewer.ReportName properties to the appropriate report definition location and report name in code. For example, add the following code to the Page_Load event to load the CommonTasks.xml report definition file into the C1DocumentViewer control:

    Visual Basic
    Copy Code
    C1DocumentViewer1.FileName = "C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml"
    C1DocumentViewer1.ReportName = "01: Alternating Background (Greenbar report)"
    
    C#
    Copy Code
    C1DocumentViewer1.FileName = "@C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml";
    C1DocumentViewer1.ReportName = "01: Alternating Background (Greenbar report)";
    

     

    Note: Update the directory in the code above with the correct samples installation directory on your machine.

     

     In XAML

    Set theC1DocumentViewer.FileName and C1DocumentViewer.ReportName properties to the appropriate report definition location and report name in the <my:C1DocumentViewer> tag. For example, use the following XAML to load the CommonTasks.xml report definition file into the C1DocumentViewer control:

    <my:C1DocumentViewer Name="C1DocumentViewer1" FileName="C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml" ReportName="01: Alternating Background (Greenbar report)"></my:C1DocumentViewer>

    Note: Update the directory in the code above with the correct samples installation directory on your machine.

    Run your application and observe:

    The 01: Alternating Background (Greenbar report) report has been loaded in the C1DocumentViewer control: