Code 39 (USD-3)
- 2 minutes to read
Short Description
Code 39, the first alpha-numeric symbology to be developed, is still widely used, particularly in non-retail environments. It is the standard bar code used by the United States Department of Defense, and is also used by the Health Industry Bar Code Council (HIBCC). Code 39 is also known as “3 of 9 Code“ and “USD-3“.
Bar Code Properties
The type of a bar code control’s Symbology property is Code39Generator.
The following properties are specific to the Code 39 type.
BarCodeGeneratorBase.CalcCheckSum
Gets or sets whether to calculate a checksum for the bar code.
Code39Generator.WideNarrowRatio
Gets or sets the density of a bar code’s bars.
Examples
The following code creates a Code 39 (USD-3) 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 CreateCode39BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Code 39.
barCode.Symbology = new Code39Generator();
// 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.
((Code39Generator)barCode.Symbology).CalcCheckSum = false;
((Code39Generator)barCode.Symbology).WideNarrowRatio = 2.5F;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.