Back to Devexpress

QR Code

xtrareports-11933-feature-guide-to-devexpress-reports-use-report-controls-use-bar-codes-qr-code.md

latest6.4 KB
Original Source

QR Code

  • Feb 18, 2026
  • 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.

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

Available Characters

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

ModeAvailable Characters
Numeric0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Alphanumeric0–9, A–Z (upper-case only), space, $, %, *, +, -, ., /, :
Byte/BinaryISO 8859-1

Use the barcode’s CompactionMode property to specify a data encoding mode: Numeric, AlphaNumeric, or Byte. Choose a mode that suits your data.

Add the Barcode to a Report

  1. Drag the XRBarCode item from the DX.25.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 the QR Code.

Specific Properties

XRBarCode.AutoModuleGets or sets whether the Module property value should be calculated automatically based on the barcode size.BarCodeControl.AutoModuleGets or sets a value that specifies whether the BarCodeControl.Module property value should be calculated automatically based upon the bar code’s size.QRCodeGenerator.CompactionModeGets or sets whether numeric, alphanumeric or byte mode should be used to encode the barcode’s data.QRCodeGenerator.ErrorCorrectionLevelGets or sets the amount of redundancy built into the bar code’s coding, to compensate for calculation errors.QRCodeGenerator.VersionGets or sets the barcode’s version.QRCodeGenerator.IncludeQuietZoneGets or sets whether to add a blank space around the QR code.QRCodeGenerator.LogoSpecifies the image that overlays the QR code.QRCodeGenerator.FrameOptionsGets or sets the frame for QR codes.

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

csharp
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 barcode control.
    XRBarCode barCode = new XRBarCode();

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

    // Adjust the barcode'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 barcode type.
    ((QRCodeGenerator)barCode.Symbology).CompactionMode = QRCodeCompactionMode.AlphaNumeric;
    ((QRCodeGenerator)barCode.Symbology).ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H;
    ((QRCodeGenerator)barCode.Symbology).Version = QRCodeVersion.AutoVersion;

    return barCode;
}
vb
Imports System
Imports System.Collections.Generic
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraReports.UI
' ...
Public Function CreateQRCodeBarCode(ByVal BarCodeText As String) As XRBarCode
    ' Create a barcode control.
    Dim barCode As New XRBarCode()

    ' Set the barcode's type to QRCode.
    barCode.Symbology = New QRCodeGenerator()

    ' Adjust the barcode'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 barcode type.
    CType(barCode.Symbology, QRCodeGenerator).CompactionMode = QRCodeCompactionMode.AlphaNumeric
    CType(barCode.Symbology, QRCodeGenerator).ErrorCorrectionLevel = QRCodeErrorCorrectionLevel.H
    CType(barCode.Symbology, QRCodeGenerator).Version = QRCodeVersion.AutoVersion

    Return barCode
End Function

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

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

var barCode = CreateQRCodeBarCode("012345678");

var report = new XtraReport() {
    Bands = {
        new DetailBand() {
            Controls = { barCode }
        }
    }
};
vb
Imports DevExpress.XtraPrinting.BarCode
Imports DevExpress.XtraReports.UI
'...

Private barCode = CreateQRCodeBarCode("012345678")

Dim report As New XtraReport()
Dim band = New DetailBand()
band.Controls.Add(barCode)

See Also

How to: Display QR Bar Code in BarCodeControl