同一报告中的重复条形码

Duplicate barcode in the same report

我想在同一个报告页面中打印确定数量的相同条码,我使用了这个代码但是它不起作用:

' ###### I try to repeat the function to generate the same barcode 6 times #######
Private Sub ExampleBarcode_BeforePrint(sender As Object, e As System.Drawing.Printing.PrintEventArgs) Handles Me.BeforePrint
    For i As Integer = 1 To 6
        Me.Detail.Controls.Add(CreateQRCodeBarCode("01234ft78"))
    Next
End Sub

Public Function CreateQRCodeBarCode(ByVal BarCodeText As String) As XRBarCode

    Dim barCode As New XRBarCode()

    barCode.Symbology = New Code128Generator()

    barCode.Text = BarCodeText
    barCode.Width = 240
    barCode.Height = 70

    barCode.Module = 1

    CType(barCode.Symbology, Code128Generator).CalcCheckSum = False
    CType(barCode.Symbology, Code128Generator).CharacterSet = Code128Charset.CharsetAuto
    Return barCode
End Function

您的条形码位于同一位置。您需要为每个控件设置不同的位置。为此,您可以使用 LeftFTopF 属性。
这是示例:

For i As Integer = 0 To 5
    Dim barCode = CreateQRCodeBarCode("01234ft78")
    barCode.TopF = i * barCode.HeightF

    Me.Detail.Controls.Add(barCode)
Next