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.
Connection String |
Copy Code
|
---|---|
data source=c:\data\NWIND.db |
DataSet Query |
Copy Code
|
---|---|
SELECT ContactName, CompanyName, Address, City, PostalCode, Country FROM Customers |
Property Name | Property Value |
---|---|
CanGrow | False |
ColumnCount | 3 |
ColumnSpacing | 0.2 |
ColumnDirection | AcrossDown |
Height | 1 |
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 |
If you preview the report at this point, one copy of each label appears on the page.
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; } |