Reports for WinForms | ComponentOne
In This Topic
    Using the C1ReportDesigner Control
    In This Topic

    The C1ReportDesigner control displays reports in design mode, and allows users to drag, copy, and resize report fields and sections. The control also provides an unlimited undo/redo stack and a selection mechanism designed for use with the PropertyGrid control that ships with Visual Studio.

    You can use the C1ReportDesigner control to incorporate some report design features into your applications, or you can write your own full-fledged report designer application. We include full source code for the C1ReportDesigner application that ships with Reports for WinForms and uses the C1ReportDesigner control extensively.

    Writing your own customized report designer is useful in many situations, for example:

    • You may want to integrate the designer tightly into your application, rather than running a separate application. (For example, see the report designer in Microsoft Access).
    • You may want to customize the data sources available to the user, or the types of fields that can be added to the report. (For example, you may want to use custom data source objects defined by your application).
    • You may want to provide a menu of stock report definitions that makes sense in the scope of your application and allows users to customize some aspects of each stock report. (For example, see the printing options in Microsoft Outlook).
    • You may want to write a better, more powerful report designer application than the one you use now, which makes it easier to do things that are important to you or to your co-workers. (For example, add groups of fields to the report).

    To use the C1ReportDesigner control, simply add it to a form, add a C1Report component that will contain the report you want to edit, and set the Report property in the designer control.

    When you run the project, you will see the report definition in design mode. You will be able to select, move, and resize the report fields and sections. Any changes made through the designer will be reflected in the report definition stored in the C1Report component. You can save the report at any time using the C1Report.Save method, or preview it using the C1Report.Document property and a Preview control.

    To build a complete designer, you will have to add other user interface elements:

    • A PropertyGrid control attached to the designer selection, so the user can change field and section properties.
    • A DataSource selection mechanism so the user can edit and change the report data source.
    • A Group Editor dialog box if you want to allow the user to create, remove, and edit report groups.
    • A Wizard to create new reports.
    • The usual file and editing commands so users can load and save reports, use the clipboard, and access the undo/redo mechanism built into the C1ReportDesigner control.

    Most of these elements are optional and may be omitted depending on your needs. The Report Designer application source code implements all of these, and you can use the source code as a basis for your implementation.

    About this section

    This section describes how to implement a simple report designer using the C1ReportDesigner control. The purpose of the sample designer is to illustrate how the C1ReportDesigner control integrates with a designer application. It supports loading and saving files with multiple reports, editing and previewing reports, adding and removing reports from the file, and report editing with undo/redo and clipboard support.

    Most designer applications based on the C1ReportDesigner control will have features similar to the ones described here. If you follow these steps, you will become familiar with all the basic features of the C1ReportDesigner control.

    The sample designer does not provide some advanced capabilities such as import/export, data source selection/editing, and group editing. All these features are supported by the full version of the C1ReportDesigner application, and you can refer to the source code for details on how to implement them.

    The following sections describe the step-by-step implementation of the sample designer.

    For the complete project, see the SimpleDesigner sample, which is installed in the ComponentOne Samples folder.

    See Also