This document introduces the basics of using barcodes in XtraReports,
describes the main properties required to create barcodes of different types,
and error messages one may encounter while working with barcodes.
To learn more about every barcode type, refer to the corresponding topic in
this section.
Also, see the Report Controls document, for
more information on using report controls.
A barcode control in XtraReports is represented by the XRBarCode
class instance. To insert a barcode into a report, simply drag an
XRBarCode control item from the DX.11.2: Report ControlsToolbox tab and drop it onto the
report.
After a barcode is added to the report, it's necessary to adjust the basic
properties of the barcode, and to specify its symbology type, text and
appearance.
There are a lot of standard barcode types supported by the XRBarCode
class. To specify the barcode's type you should set the XRBarCode.Symbology
property to an appropriate descendant of the BarCodeGeneratorBase
class (e.g. CodabarGenerator).
Then, the XRBarCode.Symbology
property will return an object that corresponds to a particular barcode's
symbology type, and contains all the properties required by this type.
Then, specify properties which are specific to this type of barcode. These
properties are represented by the corresponding descendants of the BarCodeGeneratorBase
class returned by the barcode's XRBarCode.Symbology property. For
instance, for the Industrial 2 of 5 barcode you
may need to change the values of its CalcCheckSum and
WideNarrowRatio properties.
Also, a barcode may contain text that is shown within the barcode. This text
is specified via the XRControl.Text
property of a barcode. Note that whether to show the text or not is specified by
the XRBarCode.ShowText
property value.
You may adjust barcode appearance settings. Use the XRBarCode.Module
property to specify the width of bars within a barcode, or set the XRBarCode.AutoModule
property to true to automatically calculate the bar width according to a
barcode's size. Also, use the XRBarCode.PaddingInfo
property to specify indent values of barcode bars within the XRBarCode control,
and the XRBarCode.BarCodeOrientation
property to specify how the barcode's bars and text are rotated.
The image below demonstrates properties required for a barcode object.
Note
Note that you can bind a barcode to data. It's
possible to bind either the XRControl.Text
or the XRControl.Tag
property of a barcode. See the Standard Data Binding document,
to learn more on how this is done.
When adjusting a barcode, either at design time or at runtime, some errors
may occur due to incorrect parameters specified for a barcode's properties. For
instance, the following error may occur:
If a barcode control is too small to represent the specified barcode type,
the following error message will be shown in place of the barcode. You may set
the XRBarCode.AutoModule
property to true to avoid this error.
If the barcode's text contains any characters that are not allowed by this
barcode type, then the following exception will be shown.