BarCodeControl Class
Displays a bar code.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v18.1.dll
Declaration
[ToolboxTabName("DX.18.1: Common Controls")]
[ToolboxBitmap(typeof(ToolboxIconsRootNS), "BarCodeControl")]
public class BarCodeControl :
BaseControl
Remarks
The BarCodeControl supports multiple bar code types. The following images illustrate some of them.
QR Code | EAN 8 | PDF417 |
---|---|---|
The bar code type is specified by the BarCodeControl.Symbology property.
At design time within Visual Studio, you can set this property using the Properties window.
After selecting a bar code type, you can expand the Symbology property to access additional customization options.
To specify the symbology in code, create a specific BarCodeGeneratorBase descendant and assign it to the Symbology property of the BarCodeControl.
A bar code generator object provides access to additional customization properties specific to the selected bar code type.
Some of the main bar code options are described below.
- The bar code is generated from the BarCodeControl‘s Text. To prevent the text from being displayed next to the bar code, use the BarCodeControl.ShowText property.
- To define the orientation of a bar code and its text, use the BarCodeControl.Orientation property.
To specify the width of bars within a bar code, do one of the following.
- Define a specific bar width by using the BarCodeControl.Module property.
- Enable the BarCodeControl.AutoModule property to automatically calculate the bar width according to the BarCodeControl‘s dimensions.
Note
To learn how to ensure a correct rendering and scanning of a bar code, see Bar Code Recognition Specifics.
To specify the alignment of a bar code and/or its text, use the following properties.
Example
This example illustrates how to use BarCodeControl to display a QR code.
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraEditors;
BarCodeControl barCodeControl1 = new BarCodeControl();
barCodeControl1.Parent = this;
barCodeControl1.Size = new System.Drawing.Size(150, 150);
barCodeControl1.AutoModule = true;
barCodeControl1.Text = "1234567890";
QRCodeGenerator symb = new QRCodeGenerator();
barCodeControl1.Symbology = symb;
// Adjust the QR barcode's specific properties.
symb.CompactionMode = QRCodeCompactionMode.AlphaNumeric;
symb.ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
symb.Version = QRCodeVersion.AutoVersion;
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BarCodeControl class.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.