ActiveReports 6 Online Help
Address Labels
Show AllShow All
Hide AllHide All

ActiveReports can be used to print any label size by using the newspaper column layout.

This walkthrough illustrates how to create a report that repeats labels using the LayoutAction property and prints labels to a laser printer. The labels in this example are 1" x 2.5" and print 30 labels per 8½" x 11" sheet.

The walkthrough is split up into the following activities:

Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB (on a 64-bit Windows operating system, a copy is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.MDB).

When you have finished this walkthrough, you will have a report that looks similar to the following.

To connect the report to a database

  1. Add a report to a Visual Studio project, naming it rptLabels.
  2. Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog.
  3. On the OLE DB tab, next to Connection String, click the Build button.
  4. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button.
  5. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to close the window and fill in the Connection String field.
  7. In the Query field, paste the following SQL query.
    SQL Query
    Copy Code
    SELECT ContactName, CompanyName, Address, City, PostalCode, Country FROM Customers
  8. Click OK to return to the report design surface.

To add controls to the report

  1. Remove the PageHeader and Footer sections from the report by right-clicking in the PageHeader section and selecting Delete.
  2. In the Report menu, select Settings and change the margins as follows:
    • Top margin: 0.5
    • Bottom margin: 0.5
    • Left margin: 0.2
    • Right margin: 0.2
  3. Select rptLabels in the Properties Window and Set the PrintWidth property of the report to 8.1 (the width of the label sheet less the Left and Right margins).
  4. Click on the detail section of the report to select it and make the following changes:
    • Set the CanGrow property to False (to maintain the label size)
    • Change the ColumnCount property to 3 (for three labels across the page)
    • Change the ColumnDirection property to AcrossDown (to have labels print in left-to-right order instead of top-to-bottom)
    • Set the ColumnSpacing property to 0.2 (to allow for blank space between labels)
    • Set the height of the Detail section to 1 (the height of the label, one inch)
  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the Size and Location properties of each textbox as indicated.
    Note: When you drag a field from the Report Explorer onto the design surface of the report, the DataField, Name and Text properties of the textbox object are automatically set to txtFieldName1.

    Detail fields

  6. Select all of the textboxes, and in the Properties Window, set the CanGrow property to False. This prevents overlapping text, but may crop data if one of the fields contains more data than the control size allows.

If you preview the report at this point, one copy of each label appears on the page.

To add code to the detail_Format event to repeat labels

  1. Double-click in the detail section to create a detail_Format event.
  2. Add the following code to the event to repeat each label across all three columns.

To write the code in Visual Basic.NET

To write the code in C#

See Also

Related Sections