ECC200 - Data Matrix
- 3 minutes to read
Short Description
Data Matrix code (ISO/IEC 16022 international standard) is a two-dimensional matrix bar code consisting of black and white “cells” arranged in a rectangular pattern. The information to be encoded can be text or raw data.
Every Data Matrix is composed of two solid adjacent borders in an “L” shape (called the “finder pattern”), and two other borders consisting of alternating dark and light cells or modules (called the “timing pattern”). Within these borders are rows and columns of cells that encode information. The finder pattern is used to locate and orient the symbol, while the timing pattern provides a count of the number of rows and columns in the symbol.
Bar Code Properties
The type of a bar code control’s Symbology property is DataMatrixGenerator.
The following properties are specific to the ECC200 - Data Matrix type.
XRBarCode.AutoModule/BarCodeControl.AutoModule
Gets or sets whether the Module property value should be calculated automatically based upon the barcode’s size.
DataMatrixGenerator.CompactionMode
Gets or sets whether textual information or a byte array should be used as the bar code’s data, as well as its encoding.
DataMatrixGenerator.MatrixSize
Gets or sets the bar code matrix size.
Examples
The following code creates a ECC200 - Data Matrix 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 CreateDataMatrixBarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to DataMatrix.
barCode.Symbology = new DataMatrixGenerator();
// Adjust the bar code's main properties.
barCode.Text = BarCodeText;
barCode.Width = 400;
barCode.Height = 150;
// If the AutoModule property is set to false, uncomment the next line.
barCode.AutoModule = true;
//barcode.Module = 3;
// Adjust the properties specific to the bar code type.
((DataMatrixGenerator)barCode.Symbology).CompactionMode = DataMatrixCompactionMode.Text;
((DataMatrixGenerator)barCode.Symbology).MatrixSize = DataMatrixSize.MatrixAuto;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.