本主题阐述了如何把 Interleaved 2 of 5 码制 (编码类型) 的条形码控件插入到报表中。 另外还简要说明了 Interleaved 2 of 5 编码类型。 要学习更多关于 XtraReports 的条形码的内容,请参阅 条形码概述 主题。
简要说明
Interleaved 2 of 5 是高密度的数字码制,以 Standard 2 of 5 码制为基础。 主要用于配送和仓库产业。
条形码的属性
应设置下列属性,来指定 Interleaved 2 of 5 类型的特殊条形码:
- BarCodeGeneratorBase.CalcCheckSum - 此属性用于指定是否计算条形码的校验和。 默认值是 true。
- Interleaved2of5Generator.WideNarrowRatio - 此属性用于指定条形码的条密度。 指派的取值应大于或等于 2.5。
示例
这个示例展示了如何创建一个 Interleaved 2 of 5 条形码,并设置它的基本属性。
C# | 复制代码 |
---|---|
using DevExpress.XtraReports.UI; using DevExpress.XtraPrinting.BarCode; // ... private void button1_Click(object sender, System.EventArgs e) { XtraReport1 report = new XtraReport1(); // Create a barcode control. XRBarCode barcode = new XRBarCode(); // Set the barcode's type to Interleaved 2 of 5. barcode.Symbology = new Interleaved2of5Generator(); // Adjust the Interleaved 2 of 5 barcode's main properties. barcode.Text = "0123456789"; barcode.Width = 400; barcode.Height = 100; // Adjust the Interleaved 2 of 5 barcode's specific properties. ((Interleaved2of5Generator)barcode.Symbology).CalcCheckSum = false; ((Interleaved2of5Generator)barcode.Symbology).WideNarrowRatio = 3; report.Detail.Controls.Add(barcode); report.ShowPreview(); } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraReports.UI Imports DevExpress.XtraPrinting.BarCode ' ... Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Button1.Click Dim report As New XtraReport1() ' Create a barcode control. Dim Barcode As New XRBarCode() ' Set the barcode's type to Interleaved 2 of 5. Barcode.Symbology = New Interleaved2of5Generator() ' Adjust the Interleaved 2 of 5 barcode's main properties. Barcode.Text = "0123456789" Barcode.Width = 400 Barcode.Height = 100 ' Adjust the Interleaved 2 of 5 barcode's specific properties. Dim Interleaved2of5Symbology As Interleaved2of5Generator = Barcode.Symbology Interleaved2of5Symbology.CalcCheckSum = False Interleaved2of5Symbology.WideNarrowRatio = 3 report.Detail.Controls.Add(Barcode) report.ShowPreview() End Sub |