This example demonstrates how to create a label report at runtime.
To create a report formatted to fit your labels, it is necessary to adjust some specific layout settings. Users can create labels using the Label Report Wizard with just a few clicks. However, sometimes you need to create labels at runtime. This example shows what report settings need to be configured for a particular type of label.
This example uses the CustomLabelReportBuilder
helper class that follows the report creation algorithm used by our Label Report Wizard. A CustomLabelReportModel
class implements the following label settings.
LabelWidth
,LabelHeight
Specifies the width and height of XRPanel placed into the Detail report band.HorizontalPitch
Specifies the Detail band's multi-column settings: MultiColumn.ColumnWidth and MultiColumn.ColumnSpacing.VerticalPitch
Defines the DetailBand.Height property.MeasurementUnit
Defines the XtraReport.ReportUnit property.PaperKindID
Converts to a corresponding System.Drawing.Printing.PaperKind enumeration value that is further passed to the XtraReport.PaperKind property.TopMargin
,LeftMargin
Defines the top and left report margins.BottomMargin and RightMargin
These are empty spaces that appear on the resulting report page as right and bottom spaces. These values are calculated based on other settings.
The CustomLabelReportBuilder.GenerateLabelReport
method generates a report with a CustomLabelReportModel
object or individual settings (listed above) as an argument(s).
The LabelReportValuesHelper
class has methods used to fetch label report type settings, such as Label Products list or Product Details.
You can store label settings in custom XML
files. To do this, you must pass the path to the custom XML file to the LabelReportValuesHelper
constructor.
The standard label report wizard can retrieve custom XML. Use the static DevExpress.Data.XtraReports.Labels.LabelWizardCustomization.ExternalLabelProductRepository property at the application start to specify a path to an XML file.
- Form1.cs (VB: Form1.vb)
- CustomLabelReportBuilder.cs (VB: CustomLabelReportBuilder.vb)
- CustomLabelReportModel.cs (VB: CustomLabelReportModel.vb)
- LabelReportValuesHelper.cs (VB: LabelReportValuesHelper.vb)
- Program.cs (VB: Program.vb)
- Create Labels and Badges
- Report Wizard - Labels
- Bind a Report to a Microsoft SQL Server Database at Runtime
(you will be redirected to DevExpress.com to submit your response)