Skip to main content

GS1 DataBar

  • 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).

Barcode - GS1 DataBar

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.23.2: Report Controls tab and drop it onto the report.

    Add the XBarCode item to the Report

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

    Specify the Symbology for the Barcode

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

Specific Properties

  • FNC1Substitute

    Specifies the symbol (or set of symbols) in the barcode text that are replaced with the FNC1 functional character when the barcode’s bars are drawn.

  • Type

    Gets or sets the type of the GS1 DataBar barcode.

  • SegmentsInRow

    Gets or sets the number of data segments per row in the Expanded Stacked type of the GS1 DataBar barcode.

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

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;
}

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

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

var barCode = CreateDataBarGS1BarCode("012345678");

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