Meerdere pagina's afdrukken PrintDocument

Status
Niet open voor verdere reacties.

Deadloser541

Nieuwe gebruiker
Lid geworden
16 mrt 2013
Berichten
4
Ik ben een programma aan het maken, over een facturatie systeem over vleesartikelen.
Maar ik heb een probleem het programma is bijna af, maar bij het afdrukken gaat het volledig mis.
Ik wil een factuur maken maar als er 43 artikelen op een pagina staan moet deze automatisch verder gaan naar de 2de pagina.

Maar dit lukt niet. Ik heb de code al enkele keren aangepast, maar hij schrijft wel verder maar dit doet hij op de eerste pagina zodat alles over elkaar is geschreven.

Dit is de code:

Code:
        Dim FactuurVleesFontNormaalKlein As Font = New Drawing.Font("Arial", 9)
        Dim FactuurVleesFontKlein As Font = New Drawing.Font("Arial", 7.5)
        Dim FactuurVleesFontNormaal As Font = New Drawing.Font("Arial", 10)
        Dim FactuurVleesFontGroot As Font = New Drawing.Font("Arial", 28, FontStyle.Italic)
        Dim FactuurVleesFontNormaalKleinVet As Font = New Drawing.Font("Arial", 8.5, FontStyle.Bold)
        Dim FactuurVleesFontTeBetalen As Font = New Drawing.Font("Arial", 12, FontStyle.Bold)
        Dim FactuurVleesFontNormaalVet As Font = New Drawing.Font("Arial", 11, FontStyle.Bold)
        Dim i As Decimal = 340
        Dim aantalitems As Integer = frmStap3Vlees.ListView1.Items.Count.ToString

        e.Graphics.DrawImage(Image.FromFile(My.Settings.Logo), 30, 20, 395, 80)
        e.Graphics.DrawString("Adres:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 80)
        e.Graphics.DrawString("GSM:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 114)
        e.Graphics.DrawString("Website:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 131)
        e.Graphics.DrawString("BTW nummer:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 148)
        e.Graphics.DrawString(My.Settings.NaamBank & " IBAN:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 165)
        e.Graphics.DrawString("BIC:", FactuurVleesFontNormaalKlein, Brushes.Black, 105, 182)
        e.Graphics.DrawString(My.Settings.StraatEnHuisnummerFACTUUR, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 80)
        e.Graphics.DrawString(My.Settings.PostcodeEnGemeenteFACTUUR, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 97)
        e.Graphics.DrawString(My.Settings.GSMNummer, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 114)
        e.Graphics.DrawString(My.Settings.Website, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 131)
        e.Graphics.DrawString(My.Settings.IdentificatieNummerBTW & " " & My.Settings.BTWNummer, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 148)
        e.Graphics.DrawString(My.Settings.IBAN, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 165)
        e.Graphics.DrawString(My.Settings.BIC, FactuurVleesFontNormaalKlein, Brushes.Black, 250, 182)
        e.Graphics.DrawString("Factuur", FactuurVleesFontGroot, Brushes.DarkSlateGray, 555, 40)
        e.Graphics.DrawString("Factuurnummer: " & Date.Today.Year & " - " & My.Settings.FactuurCodeVlees & " - " & My.Settings.FactuurnummerVlees, FactuurVleesFontNormaalKleinVet, Brushes.Black, 560, 97)
        Me.dtpFactuurDatum.Format = DateTimePickerFormat.Short
        Me.dtpVerval.Format = DateTimePickerFormat.Short
        e.Graphics.DrawString("Datum: " & Me.dtpFactuurDatum.Value, FactuurVleesFontNormaalKleinVet, Brushes.Black, 560, 114)
        e.Graphics.DrawString("Vervaldatum: " & Me.dtpVerval.Value, FactuurVleesFontNormaalKleinVet, Brushes.Black, 560, 131)

        e.Graphics.DrawString(frmKlantToevoegen.TblKlantenComboBox.Text, FactuurVleesFontNormaal, Brushes.Black, 450, 190)
        e.Graphics.DrawString(frmKlantToevoegen.StraatnaamTextBox.Text & " " & frmKlantToevoegen.HuisnummerTextBox.Text, FactuurVleesFontNormaal, Brushes.Black, 450, 210)
        e.Graphics.DrawString(frmKlantToevoegen.PostcodeTextBox.Text & " " & frmKlantToevoegen.GemeenteTextBox.Text, FactuurVleesFontNormaal, Brushes.Black, 450, 230)
        e.Graphics.DrawString(frmKlantToevoegen.BTW_nummerTextBox.Text, FactuurVleesFontNormaal, Brushes.Black, 450, 250)

        For t As Integer = 0 To 21 Step (+1)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 32, 315 + t, 790, 315 + t)
        Next

        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(0).Text, FactuurVleesFontKlein, Brushes.White, 35, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(1).Text, FactuurVleesFontKlein, Brushes.White, 280, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(2).Text, FactuurVleesFontKlein, Brushes.White, 360, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(3).Text, FactuurVleesFontKlein, Brushes.White, 440, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(4).Text, FactuurVleesFontKlein, Brushes.White, 520, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(5).Text, FactuurVleesFontKlein, Brushes.White, 600, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(6).Text, FactuurVleesFontKlein, Brushes.White, 680, 320)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(7).Text, FactuurVleesFontKlein, Brushes.White, 740, 320)

        Dim itemnummer As String = aantalitems

        For teller As Integer = 1 To aantalitems Step (+1)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).Text, FactuurVleesFontKlein, Brushes.Black, 35, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(1).Text, FactuurVleesFontKlein, Brushes.Black, 280, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(2).Text, FactuurVleesFontKlein, Brushes.Black, 360, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(3).Text, FactuurVleesFontKlein, Brushes.Black, 440, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(4).Text, FactuurVleesFontKlein, Brushes.Black, 520, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(5).Text, FactuurVleesFontKlein, Brushes.Black, 600, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(6).Text, FactuurVleesFontKlein, Brushes.Black, 680, i)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(teller - 1).SubItems(7).Text, FactuurVleesFontKlein, Brushes.Black, 740, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 32, 315, 32, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 790, 315, 790, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 278, 315, 278, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 358, 315, 358, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 438, 315, 438, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 518, 315, 518, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 598, 315, 598, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 678, 315, 678, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 738, 315, 738, i)
            i = i + 15
            e.Graphics.DrawLine(Pens.CornflowerBlue, 32, 315, 32, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 790, 315, 790, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 278, 315, 278, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 358, 315, 358, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 438, 315, 438, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 518, 315, 518, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 598, 315, 598, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 678, 315, 678, i)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 738, 315, 738, i)

            If (i > e.MarginBounds.Height + 20) Then

                e.Graphics.DrawLine(Pens.CornflowerBlue, 32, i, 790, i)

                i = 100

                e.HasMorePages = True

                For t As Integer = 0 To 21 Step (+1)
                    e.Graphics.DrawLine(Pens.CornflowerBlue, 32, i + t, 790, i + t)
                Next

                i = i + 21
                i = i - 16

                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(0).Text, FactuurVleesFontKlein, Brushes.White, 35, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(1).Text, FactuurVleesFontKlein, Brushes.White, 280, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(2).Text, FactuurVleesFontKlein, Brushes.White, 360, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(3).Text, FactuurVleesFontKlein, Brushes.White, 440, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(4).Text, FactuurVleesFontKlein, Brushes.White, 520, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(5).Text, FactuurVleesFontKlein, Brushes.White, 600, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(6).Text, FactuurVleesFontKlein, Brushes.White, 680, i)
                e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(7).Text, FactuurVleesFontKlein, Brushes.White, 740, i)

                i = i + 17

                e.Graphics.DrawRectangle(Pens.CornflowerBlue, 32, 315, 758, 21)
            Else
                e.HasMorePages = False

            End If
        Next
        e.Graphics.DrawLine(Pens.CornflowerBlue, 32, i, 790, i)

        For k As Integer = 0 To 63 Step (+1)
            e.Graphics.DrawLine(Pens.Black, 547, i + 38 + k, 790, i + 38 + k)
        Next

        e.Graphics.DrawString("Bedrag excl. BTW:", FactuurVleesFontNormaal, Brushes.White, 550, i + 40)
        e.Graphics.DrawString("BTW bedrag:", FactuurVleesFontNormaal, Brushes.White, 550, i + 60)
        e.Graphics.DrawString("Te betalen:", FactuurVleesFontNormaal, Brushes.White, 550, i + 82)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVleesBTW, 2).ToString("0.00"), FactuurVleesFontNormaal, Brushes.White, 705, i + 40)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVlees - My.Settings.TotaalFactuurVleesBTW, 2).ToString("0.00"), FactuurVleesFontNormaal, Brushes.White, 705, i + 60)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVlees, 2).ToString("0.00"), FactuurVleesFontTeBetalen, Brushes.White, 705, i + 80)
        e.Graphics.DrawString("Te vermelden bij betaling:", FactuurVleesFontNormaal, Brushes.Black, 31, i + 42)
        e.Graphics.DrawString(Date.Today.Year & " - " & My.Settings.FactuurCodeVlees & " - " & My.Settings.FactuurnummerVlees, FactuurVleesFontNormaalVet, Brushes.Black, 32, i + 62)

        If rbnContant.Checked = True And rbnVoldaan.Checked = True Then
            For l As Integer = 0 To 63 Step (+1)
                e.Graphics.DrawLine(Pens.Yellow, 400, i + 38 + l, 547, i + 38 + l)
            Next

            e.Graphics.DrawString("VOLDAAN", New Font("Arial", 14), Brushes.Black, 423, i + 48)
            e.Graphics.DrawString("(CASH)", New Font("Arial", 9), Brushes.Black, 452, i + 73)
        ElseIf rbnOverschrijving.Checked = True And rbnVoldaan.Checked = True Then
            For l As Integer = 0 To 63 Step (+1)
                e.Graphics.DrawLine(Pens.Yellow, 400, i + 38 + l, 547, i + 38 + l)
            Next

            e.Graphics.DrawString("VOLDAAN", New Font("Arial", 14), Brushes.Black, 423, i + 48)
            e.Graphics.DrawString("(OVERSCHRIJVING)", New Font("Arial", 9), Brushes.Black, 413.5, i + 73)
        ElseIf rbnCheque.Checked = True And txtNummer.Text <> "" Then
            For l As Integer = 0 To 63 Step (+1)
                e.Graphics.DrawLine(Pens.Yellow, 400, i + 38 + l, 547, i + 38 + l)
            Next

            e.Graphics.DrawString("VOLDAAN", New Font("Arial", 14), Brushes.Black, 423, i + 48)
            e.Graphics.DrawString("(CHEQUE: " & txtNummer.Text & ")", New Font("Arial", 9), Brushes.Black, 415, i + 73)
        End If

Dit is het resultaat:

FactuurVoorbeeld.jpg

Bedankt!
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan