私はすべてを揃えようとしていますが、方法が完全にはわかりません...これは私が作ったものですが、アイテムの名前、価格、その他は揃えられていません...それらを揃える方法はありますか? これが私のコードです...
Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim printFont As New Font("Courier New", 10)
'Dim headingFont As New Font("Courier New", 10)
Dim sngLineHeight As Single = printFont.GetHeight + 2
Dim sngXLocation As Single = e.MarginBounds.Left
Dim sngYLocation As Single = e.MarginBounds.Top
Dim intItemCount As Integer
e.Graphics.DrawString(" XXXX Restaurant ", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString(" RECEIPT ", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("========================================================", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString(DateTime.Now.ToString("hh:mm dddd, dd MMMM yyyy"), printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
Dim ptOne As Point
Dim ptTwo As Point
ptOne.X = 10
ptOne.Y = 10
ptTwo.X = 10
ptTwo.Y = 200
e.Graphics.DrawLine(Pens.Black, ptOne, ptTwo)
intItemCount = frmSalesManagement.dgvSaleManagement.Rows.Count
Dim strItemDesc As String
Dim strItemDesc2 As String
Dim strItemDesc3 As String
Dim strItemDesc4 As String
Dim strTableNo As String
Dim strNoOfPerson As String
strTableNo = frmSalesManagement.txtTableNo.Text
strNoOfPerson = frmSalesManagement.txtNoOfPerson.Text
If frmSalesManagement.lblMemberName.Text <> "" Then
e.Graphics.DrawString("Member's Name : " & frmSalesManagement.lblMemberName.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Member's Discount : 10%", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
End If
e.Graphics.DrawString("Table No.: " & strTableNo, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("No of Person : " & strNoOfPerson, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("ItemName" & vbTab & "" & vbTab & "Price" & vbTab & "" & vbTab & "Quantity" & vbTab & "" & vbTab & "Subtotal", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
For i As Integer = 0 To intItemCount - 1
strItemDesc = frmSalesManagement.dgvSaleManagement.Rows(i).Cells(0).FormattedValue.ToString() + "" & vbTab & "" & vbTab
strItemDesc2 = frmSalesManagement.dgvSaleManagement.Rows(i).Cells(1).FormattedValue.ToString() + "" & vbTab & "" & vbTab
strItemDesc3 = frmSalesManagement.dgvSaleManagement.Rows(i).Cells(2).FormattedValue.ToString() + "" & vbTab & "" & vbTab
strItemDesc4 = frmSalesManagement.dgvSaleManagement.Rows(i).Cells(3).FormattedValue.ToString() + "" & vbTab & "" & vbTab
e.Graphics.DrawString(strItemDesc & strItemDesc2 & strItemDesc3 & strItemDesc4, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
Next
If lblMethodOfPayment.Text = "Cash" Then
e.Graphics.DrawString("Payment Method : " & lblMethodOfPayment.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("Discount : " & frmSalesManagement.txtDiscount.Text.ToString() & "%", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Due Amount : RM" & lblDueAmount.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Amount Paid : RM" & txtAmountPaid.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Change : RM" & lblChange.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("======================= Thank You ======================", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("========================== End =========================", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
ElseIf lblMethodOfPayment.Text = "Visa Card" Or lblMethodOfPayment.Text = "Master Card" Then
e.Graphics.DrawString("Payment Method : " & lblMethodOfPayment.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("Discount : " & frmSalesManagement.txtDiscount.Text.ToString() & "%", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Due Amount : RM" & lblDueAmount.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Amount Paid : RM" & txtAmountPaid.Text.ToString, printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("======================= Thank You ======================", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("========================== End =========================", printFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
End If
sngYLocation += sngLineHeight
End Sub