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

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

    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 the Add Reference option from the Project menu of your project.
    4. Select the ComponentOne WPFReport 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 open the Code view. At the top of the file, add the following Imports statement (using in C#):

    Imports C1.C1Preview

    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. From the Toolbox, 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 from the Properties window set the Button.Content property to "View document".
    4. Double-click the Button control to open the Code view, and add the following code to the Button_Click handler:
    Visual Basic
    Copy Code
    Dim doc As New C1.C1Preview.C1PrintDocument()
    doc.Body.Children.Add(New RenderText("Hello World!"))
    DocumentViewer1.Document = doc.FixedDocumentSequence
    

     

    C#
    Copy Code
    C1.C1Preview.C1PrintDocument doc = new C1.C1Preview.C1PrintDocument();
    doc.Body.Children.Add(new RenderText("Hello World!"));
    documentViewer1.Document = doc.FixedDocumentSequence;
    

     

    1. Run the application and click the View document button. The report will take a few seconds to load, and should look similar to the following:

    See Also