Back to Devexpress

GS1 DataBar

xtrareports-16069-feature-guide-to-devexpress-reports-use-report-controls-use-bar-codes-gs1-databar.md

latest4.1 KB
Original Source

GS1 DataBar

  • Feb 18, 2026
  • 2 minutes to read

The GS1 DataBar barcode is based on a family of symbols often used in the GS1 DataBar Coupon (coupon codes are commonly used in retail).

Refer to the following article for more details: GS1 DataBar.

Add the Bar Code 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 DataBar (an object of the DataBarGenerator type).

  3. Specify common barcode properties and properties specific to GS1 DataBar.

Specific Properties

Runtime Example

The following code creates the GS1 DataBar 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 CreateDataBarGS1BarCode(string BarCodeText) {
    // Create a barcode control.
    XRBarCode barCode = new XRBarCode();

    // Set the barcode's type to GS1 DataBar.
    barCode.Symbology = new DataBarGenerator();

    // Adjust the barcode's main properties.
    barCode.Text = BarCodeText;
    barCode.Width = 250;
    barCode.Height = 160;

    // Adjust the properties specific to the barcode type.
    ((DataBarGenerator)barCode.Symbology).FNC1Substitute = "#";
    ((DataBarGenerator)barCode.Symbology).SegmentsInRow = 4;
    ((DataBarGenerator)barCode.Symbology).Type = DataBarType.ExpandedStacked;

    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 CreateDataBarGS1BarCode(ByVal BarCodeText As String) As XRBarCode
    ' Create a barcode control.
    Dim barCode As New XRBarCode()

    ' Set the barcode's type to GS1 DataBar.
    barCode.Symbology = New DataBarGenerator()

    ' Adjust the barcode's main properties.
    barCode.Text = BarCodeText
    barCode.Width = 250
    barCode.Height = 160

    ' Adjust the properties specific to the barcode type.
    CType(barCode.Symbology, DataBarGenerator).FNC1Substitute = "#"
    CType(barCode.Symbology, DataBarGenerator).SegmentsInRow = 4
    CType(barCode.Symbology, DataBarGenerator).Type = DataBarType.ExpandedStacked

    Return barCode
End Function

The code example below shows how to create a report with the GS1 DataBar barcode:

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

var barCode = CreateDataBarGS1BarCode("012345678");

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

Private barCode = CreateDataBarGS1BarCode("012345678")

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