The requested page is not available for the requested platform. You are viewing the content for Default platform.

Code 128

Short Description

Code 128 is a very effective, high-density symbology which permits the encoding of alphanumeric data. The symbology includes a checksum digit for verification, and the bar code can also be verified character-by-character, allowing the parity of each data byte to be verified.

This symbology has been widely implemented in many applications where a relatively large amount of data must be encoded in a relatively small amount of space. Its specific structure also allows numerical data to be effectively encoded at double-density.

Barcode - Code 128

Bar Code Properties

The type of a bar code control's Symbology property is Code128Generator.

The following property is specific to the Code 128 type.

Examples

The following code creates a Code 128 bar code and specifies its main properties.

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

    // Set the bar code's type to Code 128.
    barCode.Symbology = new Code128Generator();

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

    // Adjust the properties specific to the bar code type.
    ((Code128Generator)barCode.Symbology).CharacterSet = Code128Charset.CharsetB;

    return barCode;
}

To add the XRBarCode to a report band, handle the report's XRControl.BeforePrint event.

using System.Drawing.Printing;
// ...

private void XtraReport1_BeforePrint(object sender, PrintEventArgs e) {
    this.Detail.Controls.Add(CreateCode128BarCode("012345678"));
}