ComponentOne Reports for WinForms Designer Edition: ComponentOne Reports for WinForms > Getting Started with Reports for WinForms > Getting Started with Reporting > C1Report Quick Start > Step 1 of 4: Creating a Report Definition

Step 1 of 4: Creating a Report Definition

The following topic shows how you can create a report definition using the C1ReportDesigner. Note that creating a report definition is not the same as rendering a report. To render a report, you can simply load an existing definition and call the C1Report.Render method. The easiest way to create a report definition is to use the C1ReportDesigner, which is a stand-alone application similar to the report designer in Microsoft Access.

Note: You can also create reports from scratch, using code. This approach requires some extra work, but it gives you complete flexibility. You can even write your own report designer or ad-hoc report generator. For details, see Creating a Report Definition.

The C1Report Wizard walks you through the steps of creating a new report from start to finish. To begin, complete the following steps:

1.   To begin, create a .NET project and add the C1Report component to your Toolbox. For more information on creating a new project, see Creating a .NET Project.

2.   From the Toolbox, double-click the C1Report icon to add the component to your project. Note that the component will appear below the form in the Component Tray.

3.   Click the C1Report component’s smart tag and select Edit Report from its Tasks menu.

 

 

The C1ReportDesigner opens and the C1Report Wizard is ready to guide you through five easy steps.

From the C1Report Wizard, complete the five following steps to create your report:

1.   Select the data source for the new report.

Use this page to select the DataSource.ConnectionString and DataSource.RecordSource that will be used to retrieve the data for the report.

You can specify the DataSource.ConnectionString in three ways:

      Type the string directly into the editor.

      Use the drop-down list to select a recently used connection string (the Designer keeps a record of the last eight connection strings).

      Click the ellipsis button (…) to bring up the standard connection string builder.

You can specify the DataSource.RecordSource string in two ways:

      Click the Table option and select a table from the list.

      Click the SQL option and type (or paste) an SQL statement into the editor.

Complete Step 1:

Complete the following steps:

1.   Click the ellipsis button to bring up the standard connection string builder.

2.   Select the Provider tab and select a data provider from the list. For this example, select Microsoft Jet 4.0 OLE DB Provider.

3.   Click the Next button or select the Connection tab. Now you must choose a data source.

4.   To select a database, click the ellipsis button. The Select Access Database dialog box appears. For this example, select the Nwind.mdb located in the Common folder in the ComponentOne Samples directory (by default installed in the Documents or My Documents folder). Note that this directory reflects the default installation path and its path may be different if you made changes to the installation path.

5.   Click Open. You can test the connection and click OK.

6.   Click OK to close the Select Access Database dialog box.

7.   Once you have selected your data source, you can select a table, view, or stored procedure to provide the actual data. You can specify the DataSource.RecordSource string in two ways:

      Click the Table option and select the Products table from the list.

      Click the SQL option and type (or paste) an SQL statement into the editor.

For example:

select * from products

 

8.   Click Next. The wizard will walk you through the remaining steps.

2.   Select the fields you want to include in the report.

This page contains a list of the fields available from the recordset you selected in Step 1, and two lists that define the group and detail fields for the report. Group fields define how the data will be sorted and summarized, and detail fields define what information you want to appear in the report.

You can move fields from one list to another by dragging them with your mouse pointer. Drag fields into the Detail list to include them in the report, or drag within the list to change their order. Drag fields back into the Available list to remove them from the report.

Complete Step 2:

Complete the following steps:

1.   With your mouse pointer, select the CategoryID field and drag it into the Groups list.

2.   Press the >> button to move the remaining fields into the Detail list.

 

3.   Click Next. The wizard will walk you through the remaining steps.

3.   Select the layout for the new report.

This page offers you several options to define how the data will be organized on the page. When you select a layout, a thumbnail preview appears on the left to give you an idea of what the layout will look like on the page. There are two groups of layouts, one for reports that have no groups and one for reports with groups. Select the layout that best approximates what you want the final report to look like.

This page also allows you to select the page orientation and whether fields should be adjusted to fit the page width.

The Labels layout option is used to print Avery-style labels. If you select this option, you will see a page that prompts you for the type of label you want to print.

Complete Step 3:

Complete the following steps:

1.   Keep the Outline layout.

 

2.   Click Next. The wizard will walk you through the remaining steps.

4.   Select the style for the new report.

This page allows you to select the fonts and colors that will be used in the new report. Like the previous page, it shows a preview to give you an idea of what each style looks like. Select the one that you like best (and remember, you can refine it and adjust the details later).

Complete Step 4:

1.   Select the Verdana style.

 

2.   Click Next. The wizard will walk you through the remaining steps.

5.   Select a title for the new report.

This last page allows you to select a title for the new report and to decide whether you would like to preview the new report right away or whether you would like to go into edit mode and start improving the design before previewing it.

Complete Step 5:

1.   Enter a title for the new report, Products Report, for example.

 

2.   Choose to Preview the report and click Finish.

You will immediately see the report in the preview pane of the Designer.

You will notice that the report will require some adjustments.  In the next step, you will learn how to modify the report.


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.