I am using a print preview dailog in vb .net and when I open the dialog there
are multiple pages. Everytime I press the print button only the last page
prints. I have tried so many things but can't seem to get it to work
properly. Can anyone help???
I posted a message earlier about this but from the reply I believe my code
is set up right. My print preview shows everything correctly, just wont
print right.
Below is a sample of some of my code.
Private Sub pdEarnings_PrintPage(ByVal sender As Object, ByVal ev As
System.Drawing.Printing.PrintPageEventArgs) Handles pdEarnings.PrintPage
On Error GoTo err_fill_report
cintCol1Start = 190
cintColWidth = 100
mfntPrint = New Font("Arial", 6)
msngFontHeight = mfntPrint.GetHeight(ev.Graphics)
msngYPos = 713
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "EMPLOYEE")
cintCol1Start = 350
cintColWidth = 100
msngYPos += mfntPrint.GetHeight(ev.Graphics)
mfntPrint = New Font("Arial", 5)
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "RATES")
cintCol1Start = 28
cintCol2Start = 70
cintCol3Start = 135
cintCol4Start = 270
cintCol5Start = 325
cintCol6Start = 365
cintColWidth = 100
msngYPos += mfntPrint.GetHeight(ev.Graphics)
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "BADGE")
Call DrawStringInBox(ev, cintCol2Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "DEPT")
Call DrawStringInBox(ev, cintCol3Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "EMPLOYEE NAME")
Call DrawStringInBox(ev, cintCol4Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "SHIFT")
Call DrawStringInBox(ev, cintCol5Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "BASE")
Call DrawStringInBox(ev, cintCol6Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "AVERAGE")
cintCol1Start = 495
cintColWidth = 300
mfntPrint = New Font("Arial", 9)
msngYPos = 713
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "LEAR CORPORATION CANADA LTD.")
cintCol1Start = 495
cintColWidth = 300
msngYPos += mfntPrint.GetHeight(ev.Graphics)
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "KITCHENER")
cintCol1Start = 495
cintColWidth = 300
mfntPrint = New Font("Arial", 9, FontStyle.Bold)
msngYPos = 760
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "EMPLOYEE DAILY STATEMENT OF EARNINGS")
'Production and payroll section Box 3
cintCol1Start = 125
cintCol2Start = 635
cintColWidth = 100
mfntPrint = New Font("Arial", 7, FontStyle.Bold)
msngYPos = 785
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "PRODUCTION ON")
Call DrawStringInBox(ev, cintCol2Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "PAYROLL")
cintCol1Start = 185
cintCol2Start = 250
cintCol3Start = 355
cintCol4Start = 400
cintCol5Start = 515
cintCol6Start = 610
cintCol7Start = 670
cintCol8Start = 770
cintColWidth = 200
mfntPrint = New Font("Arial", 5)
msngYPos = 800
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "REPORTED")
Call DrawStringInBox(ev, cintCol2Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "BADGED")
Call DrawStringInBox(ev, cintCol3Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "TEAM")
Call DrawStringInBox(ev, cintCol4Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "STANDARD")
Call DrawStringInBox(ev, cintCol5Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "EARNINGS")
Call DrawStringInBox(ev, cintCol6Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "SHIFT")
Call DrawStringInBox(ev, cintCol7Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "ADD")
Call DrawStringInBox(ev, cintCol8Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "GROSS")
cintCol1Start = 40
cintCol2Start = 150
cintCol3Start = 190
cintCol4Start = 255
cintCol5Start = 300
cintCol6Start = 355
cintCol7Start = 403
cintCol8Start = 460
cintCol9Start = 490
cintCol10Start = 545
cintCol11Start = 610
cintCol12Start = 670
cintCol13Start = 725
cintCol14Start = 772
cintColWidth = 200
msngYPos += mfntPrint.GetHeight(ev.Graphics)
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "PART NUMBER")
Call DrawStringInBox(ev, cintCol2Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "OP")
Call DrawStringInBox(ev, cintCol3Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "HRS.")
Call DrawStringInBox(ev, cintCol4Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "HRS.")
Call DrawStringInBox(ev, cintCol5Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "QUANTITY")
Call DrawStringInBox(ev, cintCol6Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "SIZE")
Call DrawStringInBox(ev, cintCol7Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "RATE")
Call DrawStringInBox(ev, cintCol8Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "BC")
Call DrawStringInBox(ev, cintCol9Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "REGULAR")
Call DrawStringInBox(ev, cintCol10Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "OVERTIME")
Call DrawStringInBox(ev, cintCol11Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "PREM.")
Call DrawStringInBox(ev, cintCol12Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "ON")
Call DrawStringInBox(ev, cintCol13Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "COLA")
Call DrawStringInBox(ev, cintCol14Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, "PAY")
If Me.mstrProdDateB3(y) <"" Then
'Print Production On Date in Box 3
cintCol1Start = 220
cintColWidth = 200
mfntPrint = New Font("Arial", 8, FontStyle.Bold)
msngYPos = 785
Call DrawStringInBox(ev, cintCol1Start, msngYPos, cintColWidth,
msngYPos + msngFontHeight, Me.mstrProdDateB3(y))
If Me.mblnRecdDetal3(y) = True Then
'Employee Section Details Box 3
cintCol1Start = 25
cintCol2Start = 70
cintCol3Start = 105
cintCol4Start = 265
cintCol5Start = 314
cintCol6Start = 370
cintColWidth = 250
mfntPrint = New Font("Arial", 11)
msngYPos = 755
Call DrawStringInBox(ev, cintCol1Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrBadgeB3(y))
Call DrawStringInBox(ev, cintCol2Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrDeptB3(y))
Call DrawStringInBox(ev, cintCol3Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrEmpNameB3(y))
Call DrawStringInBox(ev, cintCol4Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrShiftB3(y))
Call DrawStringInBox(ev, cintCol5Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblBaseB3(y).ToString("#.00"))
Call DrawStringInBox(ev, cintCol6Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblAverB3(y).ToString("#.00"))
'Production/payroll Section Details Box 3
cintCol1Start = 15
cintCol2Start = 43
cintCol3Start = 150
cintCol4Start = 17
cintCol5Start = 80
cintCol6Start = 135
cintCol7Start = 170
cintCol8Start = 230
cintCol9Start = 460
cintCol10Start = 328
cintCol11Start = 385
cintCol12Start = 435
cintCol13Start = 485
cintCol14Start = 550
cintCol15Start = 600
cintColWidth = 200
mfntPrint = New Font("Arial", 7, FontStyle.Regular)
msngYPos = 820
For z3 = startB3(y) To z3SaveB3(y)
Call DrawStringInBox(ev, cintCol1Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrExpB3(z3))
Call DrawStringInBox(ev, cintCol2Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrPartB3(z3))
If Me.mstrOperB3(z3) <"0" Then
Call DrawStringInBox(ev, cintCol3Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrOperB3(z3))
End If
Call DrawStringOutBox(ev, cintCol4Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblRptdHrsB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol5Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrBadgeHrsB3(z3))
If Me.mintQtyB3(z3) <0 Then
Call DrawStringOutBox(ev, cintCol6Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mintQtyB3(z3).ToString)
End If
Call DrawStringOutBox(ev, cintCol7Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mintTeamB3(z3).ToString)
Call DrawStringOutBox(ev, cintCol8Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblStandRateB3(z3).ToString("#.00"))
If Me.mstrDeptB3(y) <Me.mstrBCB3(z3) Then
Call DrawStringInBox(ev, cintCol9Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mstrBCB3(z3))
End If
Call DrawStringOutBox(ev, cintCol10Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblEarnRegB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol11Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblEarnOTB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol12Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblShftPremB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol13Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblAddOnB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol14Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblColaB3(z3).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol15Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblGrossPayB3(z3).ToString("#.00"))
msngYPos += mfntPrint.GetHeight(ev.Graphics)
Next (z3)
'print totals
cintCol1Start = 15
cintCol2Start = 17
cintCol3Start = 328
cintCol4Start = 385
cintCol5Start = 435
cintCol6Start = 485
cintCol7Start = 550
cintCol8Start = 600
mfntPrint = New Font("Arial", 7, FontStyle.Bold)
Call DrawStringInBox(ev, cintCol1Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, "TOTAL")
Call DrawStringOutBox(ev, cintCol2Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotRptHrsB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol3Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotRegEarnB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol4Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotOTEarnB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol5Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotShiftPremB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol6Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotAddOnB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol7Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, Me.mdblTotColaB3(y).ToString("#.00"))
Call DrawStringOutBox(ev, cintCol8Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight,
Me.mdblTotGrossB3(y).ToString("#.00"))
Else
cintCol1Start = 25
cintColWidth = 500
mfntPrint = New Font("Arial", 12, FontStyle.Bold)
msngYPos = 900
Call DrawStringInBox(ev, cintCol1Start, msngYPos,
cintColWidth, msngYPos + msngFontHeight, "NO EARNINGS FOR DATE SELECTED " &
Me.mstrProdDateB3(y))
End If
End If
If msngCurrentPage < msngPages Then
msngYPos = ev.MarginBounds.Top + (msngFontHeight * 5)
y += 1
msngCurrentPage += 1
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
err_fill_report:
End Sub