Report Authors / Design Reports / Design Section Reports / Tutorials: Section Report Scenarios / Create Address Labels in Section Report
Create Address Labels in Section Report

You can use ActiveReports to print any label size by using the newspaper column layout.

These steps show 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 report connects to 'NWIND.db' data source on GitHub.

The final report will look as shown.

Address Labels Section Report at Run Time

Create a Report

In the ActiveReports Designer, create a new Section report. 

Bind Report to Data

  1. As you create a new report, the Report Data Source dialog appears for you to configure the report data connection. You can also access this dialog by clicking the DataSource Icon in the Detail section band.
  2. Choose Custom tab > SQLite Provider in the Report Data Source dialog, and bind the report to SQLite data using the following connection string and query.
    Connection String
    Copy Code
    data source=c:\data\NWIND.db
    
     
    DataSet Query
    Copy Code
    SELECT ContactName, CompanyName, Address, City, PostalCode, Country FROM Customers
    
       
  3.    Click OK to close the Report Data Source dialog and return to the report design surface.

Design Report Layout

  1. Right-click the PageHeader section and select Delete to remove the PageHeader and PageFooter sections from the report.
  2. Go to Report Explorer, right-click the Settings option and select Show to view the Report Settings.
  3. Change the margins as follows:
    • Top margin: 0.5
    • Bottom margin: 0.5
    • Left margin: 0.2
    • Right margin: 0.2
  4. From the Report Explorer, select Report and in the Properties panel, set the PrintWidth property to 8.1 (the width of the label sheet less the Left and Right margins).
  5. Click the Detail section of the report to select it and in the Properties window, set the properties as follows.
    Property Name Property Value
    CanGrow False
    ColumnCount 3
    ColumnSpacing 0.2
    ColumnDirection AcrossDown
    Height 1
  6. From the toolbox, drag the following fields one below the other and set the properties of each textbox as follows.

    txtContactName1

    Property Name Property Value
    DataField ContactName
    Location 0, 0 in
    Size 2.5, 0.2 in
    Font > Bold True

    txtCompanyName1

    Property Name Property Value
    DataField CompanyName
    Location 0, 0.2 in
    Size 2.5, 0.2 in

    txtAddress1

    Property Name Property Value
    DataField Address
    Location 0, 0.4 in
    Size 2.5, 0.2 in

    txtCity1

    Property Name Property Value
    DataField City
    Location 0, 0.6 in
    Size 2.5, 0.2 in

    txtPostalCode1

    Property Name Property Value
    DataField PostalCode
    Location 0, 0.8 in
    Size 1.45, 0.2 in

    txtCountry1

    Property Name Property Value
    DataField Country
    Location 1.5, 0.8 in
    Size 1, 0.2 in
  7. Select all of the textboxes, and in the Properties Panel, 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.
    Address Labels Section Report at Design Time

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

Add Code to 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.
    Example Title
    Copy Code
    Imports GrapeCity.ActiveReports.SectionReportModel
    
    Visual Basic.NET code. Paste INSIDE the Format event
    Copy Code
    'print each label three times
    Static counter As Integer
    counter = counter + 1
    If counter <= 2 Then
        rpt.LayoutAction = GrapeCity.ActiveReports.LayoutAction.MoveLayout Or
     GrapeCity.ActiveReports.LayoutAction.PrintSection
    Else
        rpt.LayoutAction = GrapeCity.ActiveReports.LayoutAction.MoveLayout Or
     GrapeCity.ActiveReports.LayoutAction.NextRecord Or
     GrapeCity.ActiveReports.LayoutAction.PrintSection
        counter = 0
    End If
    
    C# code. Paste JUST ABOVE the Format event
    Copy Code
    using GrapeCity.ActiveReports.SectionReportModel;
    int counter=0;
    
    C# code. Paste INSIDE the Format event
    Copy Code
    //print each label three times
    counter = counter + 1;
    if (counter <= 2)
    {
        rpt.LayoutAction =  GrapeCity.ActiveReports.LayoutAction.MoveLayout|
    GrapeCity.ActiveReports.LayoutAction.PrintSection;
    }
    else
    {
        rpt.LayoutAction = GrapeCity.ActiveReports.LayoutAction.MoveLayout|
    GrapeCity.ActiveReports.LayoutAction.NextRecord|
    GrapeCity.ActiveReports.LayoutAction.PrintSection;
        counter = 0;
    }
    
  3. Improve the appearance of the report and preview.