e.Graphics.DrawString("Model No Description Guarantee Qty Unit price", PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
but now I need to get the data from the listboxes and place them under there description. Can anybody be of any help please? I have supplied my code many thanks TheCodeHunter
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
Dim invoice As Drawing.Printing.PrintDocument
invoice = New Drawing.Printing.PrintDocument()
invoice.DocumentName = "Invoice"
'wire up event for each page
AddHandler invoice.PrintPage, AddressOf Me.PrintPage
invoice.Print()
invoice.Dispose()
End Sub
Private Sub PrintPage(ByVal sender As Object, ByVal e As Drawing.Printing.PrintPageEventArgs)
Dim PrintFont As Font
Dim CurrentY As Single
'Establish font
PrintFont = New Font("Courier New", 12)
CurrentY = e.MarginBounds.Top
'Print header
PrintFont = New Font("Courier New", 12, FontStyle.Bold)
e.Graphics.DrawString("Herne Bay Domestics Ltd", PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
PrintFont = New Font("Courier New", 10, FontStyle.Bold)
CurrentY += 2 * PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format("Monkey High Street"), PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format("Monkey land"), PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format("monkey"), PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString("Vat No: " + CStr(Format("123456")), PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += 2 * PrintFont.GetHeight(e.Graphics)
PrintFont = New Font("Courier New", 12, FontStyle.Bold)
'Deliver to
PrintFont = New Font("Courier New", 12, FontStyle.Bold)
e.Graphics.DrawString("Deliver To", PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
PrintFont = New Font("Courier New", 10, FontStyle.Bold)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(Titlecombobox.Text, "") + Format(Surnametextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(Notextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(Streettextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(Towntextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(PostCodetextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += 2 * PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(TelephoneNotextbox.Text, ""), PrintFont, Brushes.Black, e.MarginBounds.Right - 100, CurrentY)
CurrentY += PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString("Invoice date:", PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += 2 * PrintFont.GetHeight(e.Graphics)
e.Graphics.DrawString(Format(DateTimePicker2.Text), PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
CurrentY += 2 * PrintFont.GetHeight(e.Graphics)
'Sub titles
PrintFont = New Font("Courier New", 12, FontStyle.Bold)
e.Graphics.DrawString("Model No Description Guarantee Qty Unit price", PrintFont, Brushes.Black, e.MarginBounds.Left, CurrentY)
PrintFont = New Font("Courier New", 12, FontStyle.Regular)
CurrentY += PrintFont.GetHeight(e.Graphics)
'Item description
'!!! Need code to display details inlistboxes
End Sub
Private Function PaymentLine(ByVal M As Integer, ByVal PA As Single, ByVal P As Single, ByVal I As Single, ByVal B As Single) As String
Dim PL As String, S As String
Dim DL As String
PL = Space(60) 'blank out line with spaces
DL = Space(10)
'Model No
S = Format(M, "#")
Mid(PL, 5 - Len(S), Len(S)) = S
'Description
S = Format(PA, "0.00")
Mid(PL, 18 - Len(S), Len(S)) = S
'Guarantee
S = Format(P, "0.00")
Mid(PL, 32 - Len(S), Len(S)) = S
'Qty
S = Format(I, "0.00")
Mid(PL, 45 - Len(S), Len(S)) = S
'Unit price
S = Format(B, "0.00")
Mid(PL, 57 - Len(S), Len(S)) = S
Return (PL)
Return (DL)
End Function