Matrix 2 of 5
- 2 minutes to read
Short Description
Matrix 2 of 5 is a linear one-dimensional bar code. Matrix 2 of 5 is a self-checking numerical-only bar code.
Unlike the Interleaved 2 of 5, all of the information is encoded in the bars; the spaces are of a fixed width and used only to separate the bars. Matrix 2 of 5 is used primarily for warehouse sorting, photo finishing, and airline ticket marking.
Bar Code Properties
The type of a bar code control’s Symbology property is Matrix2of5Generator.
The following properties are specific to the Matrix 2 of 5 type.
BarCodeGeneratorBase.CalcCheckSum
Gets or sets whether to calculate a checksum for the bar code.
Industrial2of5Generator.WideNarrowRatio
Gets or sets the density of a bar code’s bars.
Examples
The following code creates a Matrix 2 of 5 bar code and specifies its main properties.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-add-a-bar-code-to-a-report-e167.
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreateMatrix2of5BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Matrix 2 of 5.
barCode.Symbology = new Matrix2of5Generator();
// 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.
((Matrix2of5Generator)barCode.Symbology).CalcCheckSum = false;
((Matrix2of5Generator)barCode.Symbology).WideNarrowRatio = 3;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.