Skip to main content

QR Code

  • 3 minutes to read

A Quick Response (QR) Code is a two-dimensional code. QR scanners, mobile phones with a camera, and smartphones can read this code.

qrcode

Refer to the following article for more information: QR Code.

Available Characters

QR Code can encode numeric, alphanumeric, and binary data. The table below shows the available characters for each mode:

Mode

Available Characters

Numeric

0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Alphanumeric

0–9, A–Z (upper-case only), space, $, %, *, +, -, ., /, :

Byte/Binary

ISO 8859-1

Use the barcode’s CompactionMode property to specify mode (Numeric, AlphaNumeric, or Byte) that should be used to encode data. Choose mode that corresponds to the characters your data contains.

Add the Bar Code to a Report

  1. Drag the XRBarCode item from the DX.21.2: Report Controls tab and drop it onto the report.

  2. Set the XRBarCode control’s Symbology property to QRCode (an object of the QRCodeGenerator type).

  3. Specify common barcode properties and properties specific to QR Code .

Specific Properties

  • XRBarCode.AutoModule/BarCodeControl.AutoModule

    Gets or sets whether the Module property value should be calculated automatically based upon the barcode’s size.

  • CompactionMode

    Gets or sets whether numeric, alphanumeric or byte mode should be used to encode the barcode’s data.

  • ErrorCorrectionLevel

    Gets or sets the amount of redundancy built into the bar code’s coding, to compensate for calculation errors.

  • Version

    Gets or sets the bar code’s size.

  • Logo

    Specifies the image that overlays the QR code.

Runtime Example

The following code creates the QR Code barcode and specifies its properties.

View Example: How to add a bar code to a report

using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreateQRCodeBarCode(string BarCodeText) {
    // Create a bar code control.
    XRBarCode barCode = new XRBarCode();

    // Set the bar code's type to QRCode.
    barCode.Symbology = new QRCodeGenerator();

    // Adjust the bar code's main properties.
    barCode.Text = BarCodeText;
    barCode.Width = 400;
    barCode.Height = 150;

    // If the AutoModule property is set to false, uncomment the next line.
    barCode.AutoModule = true;
    // barcode.Module = 3;

    // Adjust the properties specific to the bar code type.
    ((QRCodeGenerator)barCode.Symbology).CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    ((QRCodeGenerator)barCode.Symbology).ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    ((QRCodeGenerator)barCode.Symbology).Version = QRCodeVersion.AutoVersion;

    return barCode;
}

The code example below shows how to create a report with the QR Code barcode:

using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
//...

var barCode = CreateQRCodeBarCode("012345678");

var report = new XtraReport() {
    Bands = {
        new DetailBand() {
            Controls = { barCode }
        }
    }
};
See Also