scooby36 0 Newbie Poster

Hi Guys, I have a problem getting my head around an issue with printing labels. I can get my program to print a single label from gaining the ID number for that record and using the e.drawstring method but I need to print multiple labels say from one persons ID number maybe 2 labels may be 10. I think that the best way to get the multiple records is from a stored procedure and then loop through it but thats where I get stuck!! This is the code I am using at the moment which works for the single label. Any help or pointers would be really great..

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim dpiX As Single
        Dim dpiY As Single
        Dim x As Integer
        Dim y As Integer
        Dim width As Integer
        Dim height As Integer

        ' Get the current printer resolution
        dpiX = e.Graphics.DpiX
        dpiY = e.Graphics.DpiY

        ' Set ´the barcode position
        x = e.MarginBounds.Left   ' left page coordinate (with margin) in pixels
        y = e.MarginBounds.Top    ' top  page coordinate (with margin) in pixels

        ' Set barcode dimensions
        ' Millimeter values have to be converted to dots (* 1 / 25.4).
        width = CInt(42.0 / 25.4 * dpiX)    ' the width should be 50 mm
        height = CInt(11.0 / 25.4 * dpiY)   ' the height should be 30 mm

        ' Set the bounding rectangle for the barcode:
        BarcodeControl1.Barcode.BoundingRectangle = New Rectangle(x, y, width, height)

        ' Draw barcode
        BarcodeControl1.Barcode.Draw(e.Graphics)

        e.Graphics.DrawString("" & txtName.Text, New Font("Verdana", 12, FontStyle.Regular), Brushes.Black, 9, 92)
        e.Graphics.DrawString("" & FName, New Font("Verdana", 12, FontStyle.Regular), Brushes.Black, 15, 70)
        e.Graphics.DrawString("" & LName, New Font("Verdana", 12, FontStyle.Regular), Brushes.Black, 95, 70)
        e.Graphics.DrawString("" & Loc, New Font("Verdana", 12, FontStyle.Regular), Brushes.Black, 220, 30)
        e.Graphics.DrawString("" & Loc2, New Font("Verdana", 12, FontStyle.Regular), Brushes.Black, 220, 55)
          End Sub


End Class

and to get the varibles I use another sub

Dim i As Integer
        Dim id As Integer
        Dim garmID As Integer
        Dim GID As Integer
        i = dgGarmRent.CurrentRow.Index
        id = dgEmp.CurrentRow.Index
        garmID = (dgGarmRent.Item(5, i).Value)
        GID = (dgGarmRent.Item(0, i).Value)
        FName = dgEmp.Item(1, id).Value
        LName = dgEmp.Item(2, id).Value
        Loc = IIf(IsDBNull(dgEmp.Item(3, id).Value), 0, dgEmp.Item(3, id).Value)
        Loc2 = IIf(IsDBNull(dgEmp.Item(4, id).Value), 0, dgEmp.Item(4, id).Value)

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.