Back to Devexpress

DataBarGenerator Class

corelibraries-devexpress-dot-xtraprinting-dot-barcode-db82ee90.md

latest3.6 KB
Original Source

DataBarGenerator Class

Generates a GS1 (DataBar) barcode.

Namespace : DevExpress.XtraPrinting.BarCode

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class DataBarGenerator :
    BarCodeGeneratorBase
vb
Public Class DataBarGenerator
    Inherits BarCodeGeneratorBase

Remarks

Refer to the GS1 (DataBar) topic for details on this type of barcode.

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

Inheritance

Object DevExpress.Printing.Utils.DocumentStoring.StorableObjectBase BarCodeGeneratorBase DataBarGenerator

See Also

DataBarGenerator Members

GS1 DataBar

DevExpress.XtraPrinting.BarCode Namespace