Reports for WPF | ComponentOne
Getting Started with Reports for WPF / Reports for WPF Quick Starts / C1Report Quick Start
In This Topic
    C1Report Quick Start
    In This Topic

    In this quick start you'll create a basic WPF application in Visual Studio that references Reports for WPF for previewing reports and documents.

    Note: This quick start assumes that you have the sample CommonTasks.xml report definition file available on your system. The CommonTasks.xml is installed in the samples directory by default.

    Complete the following steps to create a basic form for previewing reports and documents:

    1. Create a new WPF application in Visual Studio.
    2. Add a reference to the C1.WPF.C1Report assembly to your project:
    3. Select Project | Add Reference to open the Add Reference dialog box.
    4. Select the ComponentOne Reports for WPF assembly from the list on the .NET tab or, on the Browse tab, browse to find the C1.WPF.C1Report.dll file and click OK.
    5. Double-click the window caption area to switch to Code view. At the top of the file, add the following Imports statement (using in C#):

    Imports C1.C1Report

    This makes the objects defined in the Reports for WPF assembly visible to the project.

    1. From the View menu, select Designer to return to Design view.
    2. Navigate to the Toolbox and double-click the standard DocumentViewer and Button controls to add them to your window. Then resize the window and the control to fill the window.
    3. Select the button control and in the Properties window set the Button.Content property to "View report".
    4. Double-click the Button control to switch to Code view and create the Button_Click event handler, and add the following code to the Button_Click handler:
    Visual Basic
    Copy Code
    Dim rep As New C1.C1Report.C1Report()
    rep.Load("C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\C1WPFReport\C1Report\Samples\XML\CommonTasks\CommonTasks.xml", "01: Alternating Background (Greenbar report)")
    DocumentViewer1.Document = rep.FixedDocumentSequence
    
    C#
    Copy Code
    C1.C1Report.C1Report rep =  new C1.C1Report.C1Report();
    rep.Load(@"C:\\Documents and Settings\\<username>\\My Documents\\ComponentOne Samples\\C1WPFReport\\C1Report\\Samples\\XML\\CommonTasks\\CommonTasks.xml", @"01: Alternating Background (Greenbar report)");
    documentViewer1.Document = rep.FixedDocumentSequence;
    
    1. Run the application and click the View report button.

    The report will take a few seconds to load, and will look similar to the following:

    See Also