PrintDocument Visual Basic

Status
Niet open voor verdere reacties.

Deadloser541

Nieuwe gebruiker
Lid geworden
16 mrt 2013
Berichten
4
Ik heb gevonden hoe je 2 pagina's en meerdere aanmaakt als je artikels op je factuur plaatst.

Maar ik krijg het als voorbeeld op mijn programma (zie bijlage 1) zoals ik het wil hebben. Maar eens
ik het uitprint dan ziet het er totaal anders uit. Hoe kan dit? Hier is de code. Ik heb het in stukken verdeeld:

Dit is voor de hoofding op pagina 1 en de kolommen met de namen op elke pagina.

Code:
If r = 0 Then
            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)

            e.Graphics.DrawLine(Pens.CornflowerBlue, 30, i - 20, 30, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 278, i - 20, 278, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 358, i - 20, 358, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 438, i - 20, 438, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 518, i - 20, 518, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 598, i - 20, 598, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 738, i - 20, 738, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 800, i - 20, 800, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 30, 885, 800, 885)
            e.Graphics.DrawString(PageNumber, FactuurVleesFontNormaalKlein, Brushes.Black, 770, 30)
        Else
            e.Graphics.DrawLine(Pens.CornflowerBlue, 30, 100, 30, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 278, 100, 278, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 358, 100, 358, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 438, 100, 438, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 518, 100, 518, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 598, 100, 598, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 738, 100, 738, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 800, 100, 800, 885)
            e.Graphics.DrawLine(Pens.CornflowerBlue, 30, 885, 800, 885)
            e.Graphics.DrawString(PageNumber, FactuurVleesFontNormaalKlein, Brushes.Black, 770, 30)
        End If

        e.Graphics.FillRectangle(Brushes.CornflowerBlue, 30, i - 20, 770, 20)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(0).Text, FactuurVleesFontKlein, Brushes.White, 32, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(1).Text, FactuurVleesFontKlein, Brushes.White, 280, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(2).Text, FactuurVleesFontKlein, Brushes.White, 360, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(3).Text, FactuurVleesFontKlein, Brushes.White, 440, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(4).Text, FactuurVleesFontKlein, Brushes.White, 520, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(5).Text, FactuurVleesFontKlein, Brushes.White, 600, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(6).Text, FactuurVleesFontKlein, Brushes.White, 680, i - 15)
        e.Graphics.DrawString(frmStap3Vlees.ListView1.Columns(7).Text, FactuurVleesFontKlein, Brushes.White, 740, i - 15)

Hierna zullen de artikels in de tabellen geplaatst worden. Volgens mij gaat het hier ergens verkeerd?

Code:
 While (r < frmStap3Vlees.ListView1.Items.Count)

            If (i > 875) Then
                i = 100
                e.HasMorePages = True
                PageNumber += 1
                Return
            End If

            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).Text, FactuurVleesFontKlein, Brushes.Black, 32, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(1).Text, FactuurVleesFontKlein, Brushes.Black, 280, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(2).Text, FactuurVleesFontKlein, Brushes.Black, 360, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(3).Text, FactuurVleesFontKlein, Brushes.Black, 440, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(4).Text, FactuurVleesFontKlein, Brushes.Black, 520, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(5).Text, FactuurVleesFontKlein, Brushes.Black, 600, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(6).Text, FactuurVleesFontKlein, Brushes.Black, 680, i + 2)
            e.Graphics.DrawString(frmStap3Vlees.ListView1.Items(r).SubItems(7).Text, FactuurVleesFontKlein, Brushes.Black, 740, i + 2)

            i += 15
            r += 1

            If r = frmStap3Vlees.ListView1.Items.Count Then
                Exit While
            End If

        End While

Hierna als de artikels op de factuur zijn gezet, dan komt het kadertje met het totaal en btw enzovoort.

Code:
 For k As Integer = 0 To 63 Step (+1)
            e.Graphics.DrawLine(Pens.Black, 547, 875 + 38 + k, 800, 875 + 38 + k)
        Next

        e.Graphics.DrawString("Bedrag excl. BTW:", FactuurVleesFontNormaal, Brushes.White, 550, 875 + 40)
        e.Graphics.DrawString("BTW bedrag:", FactuurVleesFontNormaal, Brushes.White, 550, 875 + 60)
        e.Graphics.DrawString("Te betalen:", FactuurVleesFontNormaal, Brushes.White, 550, 875 + 82)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVleesBTW, 2).ToString("0.00"), FactuurVleesFontNormaal, Brushes.White, 705, 875 + 40)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVlees - My.Settings.TotaalFactuurVleesBTW, 2).ToString("0.00"), FactuurVleesFontNormaal, Brushes.White, 705, 875 + 60)
        e.Graphics.DrawString(Math.Round(My.Settings.TotaalFactuurVlees, 2).ToString("0.00"), FactuurVleesFontTeBetalen, Brushes.White, 705, 875 + 80)
        e.Graphics.DrawString("Te vermelden bij betaling:", FactuurVleesFontNormaal, Brushes.Black, 31, 875 + 42)
        e.Graphics.DrawString(Date.Today.Year & " - " & My.Settings.FactuurCodeVlees & " - " & My.Settings.FactuurnummerVlees, FactuurVleesFontNormaalVet, Brushes.Black, 32, 875 + 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, 875 + 38 + l, 547, 875 + 38 + l)
            Next

            e.Graphics.DrawString("VOLDAAN", New Font("Arial", 14), Brushes.Black, 423, 875 + 48)
            e.Graphics.DrawString("(CASH)", New Font("Arial", 9), Brushes.Black, 452, 875 + 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, 875 + 38 + l, 547, 875 + 38 + l)
            Next

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

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

Kan iemand mij helpen? Ik geraakt er niet aan uit.
Bedankt!

Bijlage 1: Zo ziet het eruit op het programma.
Factuur.jpg

Bijlage 2: Zo wordt het uitgeprint.
scannen0001.jpg
 
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan