Dim font1 As New Font("Angsana New", 19)
Dim font2 As New Font("Angsana New", 38)
Dim head As String = "ใบเสร็จรับเงิน"
Dim js As String = "ร้าน เจริญค้า"
Dim add As String = "198/8 ม.7 ต.อ่างทอง อ.เมือง จ.ราชบุรี 70000"
Dim order As String = "เลขที่ : "
Dim cusname As String = "ชื่อลูกค้า:"
Dim datess As String = "วันที่ : "
Dim typecus As String = Tb_cname.Text
Dim x As String = Tb_order.Text
Dim daytime As Date = Date.Today
Dim line As String = "______________________________________________________________________________________"
Dim deta As String = " สินค้า จำนวน หน่วย ราคา รวมเงิน"
Dim tot As String = "รวมเงินทั้งสิ้น : "
Dim sum As String = Tb_total.Text
Dim bath As String = "บาท"
Dim c1 As String = "ผู้รับของ:__________________"
Dim c2 As String = "ผู้รับเงิน:__________________"
e.Graphics.DrawString(js.ToString, font1, Brushes.Black, 50, 75)
e.Graphics.DrawString(head.ToString, font2, Brushes.Black, 300, 15)
e.Graphics.DrawString(add.ToString, font1, Brushes.Black, 50, 105)
e.Graphics.DrawString(order.ToString, font1, Brushes.Black, 50, 135)
e.Graphics.DrawString(x.ToString, font1, Brushes.Black, 110, 135)
e.Graphics.DrawString(datess.ToString, font1, Brushes.Black, 50, 165)
e.Graphics.DrawString(daytime.Date, font1, Brushes.Black, 100, 165)
e.Graphics.DrawString(cusname.ToString, font1, Brushes.Black, 50, 195)
e.Graphics.DrawString(typecus.ToString, font1, Brushes.Black, 120, 195)
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 200) 'เส้นคั่น
e.Graphics.DrawString(deta.ToString, font1, Brushes.Black, 30, 230)
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 240) 'เส้นคั่น
Dim PrintPosition As New PointF
Dim PrintColor As New SolidBrush(Color.Black)
Dim col As Integer = 50 'ยาว
Dim row As Integer = 280 'บรรทัด
Dim col1 As Integer = 340
Dim row1 As Integer = 280
Dim col2 As Integer = 440
Dim row2 As Integer = 280
Dim col3 As Integer = 640
Dim row3 As Integer = 300
Dim col4 As Integer = 790
Dim row4 As Integer = 300
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col, row)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(2).Value.ToString, font1, PrintColor, PrintPosition)
row = row + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col1, row1)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(5).Value.ToString, font1, PrintColor, PrintPosition)
row1 = row1 + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col2, row2)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(3).Value.ToString, font1, PrintColor, PrintPosition)
row2 = row2 + 30
Next
Dim format1 As New StringFormat(StringFormatFlags.NoClip)
Dim format2 As New StringFormat(format1)
format1.LineAlignment = StringAlignment.Near
format1.Alignment = StringAlignment.Center
format2.LineAlignment = StringAlignment.Center
format2.Alignment = StringAlignment.Far
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col3, row3)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(4).Value.ToString, font1, PrintColor, PrintPosition, format2)
row3 = row3 + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col4, row4)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(6).Value.ToString, font1, PrintColor, PrintPosition, format2)
row4 = row4 + 30
Next
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 950) 'เส้นคั่น
e.Graphics.DrawString(tot.ToString, font1, Brushes.Black, 520, 1000)
e.Graphics.DrawString(sum.ToString, font1, Brushes.Black, 640, 1000)
e.Graphics.DrawString(bath.ToString, font1, Brushes.Black, 750, 1000)
e.Graphics.DrawString(c1.ToString, font1, Brushes.Black, 80, 1050)
e.Graphics.DrawString(c2.ToString, font1, Brushes.Black, 85, 1110)
End Sub
Dim font1 As New Font("Angsana New", 19)
Dim font2 As New Font("Angsana New", 38)
Dim head As String = "ใบเสร็จรับเงิน"
Dim js As String = "ร้าน เจริญค้า"
Dim add As String = "198/8 ม.7 ต.อ่างทอง อ.เมือง จ.ราชบุรี 70000"
Dim order As String = "เลขที่ : "
Dim cusname As String = "ชื่อลูกค้า:"
Dim datess As String = "วันที่ : "
Dim typecus As String = Tb_cname.Text
Dim x As String = Tb_order.Text
Dim daytime As Date = Date.Today
Dim line As String = "______________________________________________________________________________________"
Dim deta As String = " สินค้า จำนวน หน่วย ราคา รวมเงิน"
Dim tot As String = "รวมเงินทั้งสิ้น : "
Dim sum As String = Tb_total.Text
Dim bath As String = "บาท"
Dim c1 As String = "ผู้รับของ:__________________"
Dim c2 As String = "ผู้รับเงิน:__________________"
e.Graphics.DrawString(js.ToString, font1, Brushes.Black, 50, 75)
e.Graphics.DrawString(head.ToString, font2, Brushes.Black, 300, 15)
e.Graphics.DrawString(add.ToString, font1, Brushes.Black, 50, 105)
e.Graphics.DrawString(order.ToString, font1, Brushes.Black, 50, 135)
e.Graphics.DrawString(x.ToString, font1, Brushes.Black, 110, 135)
e.Graphics.DrawString(datess.ToString, font1, Brushes.Black, 50, 165)
e.Graphics.DrawString(daytime.Date, font1, Brushes.Black, 100, 165)
e.Graphics.DrawString(cusname.ToString, font1, Brushes.Black, 50, 195)
e.Graphics.DrawString(typecus.ToString, font1, Brushes.Black, 120, 195)
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 200) 'เส้นคั่น
e.Graphics.DrawString(deta.ToString, font1, Brushes.Black, 30, 230)
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 240) 'เส้นคั่น
Dim PrintPosition As New PointF
Dim PrintColor As New SolidBrush(Color.Black)
Dim col As Integer = 50 'ยาว
Dim row As Integer = 280 'บรรทัด
Dim col1 As Integer = 340
Dim row1 As Integer = 280
Dim col2 As Integer = 440
Dim row2 As Integer = 280
Dim col3 As Integer = 640
Dim row3 As Integer = 300
Dim col4 As Integer = 790
Dim row4 As Integer = 300
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col, row)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(2).Value.ToString, font1, PrintColor, PrintPosition)
row = row + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col1, row1)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(5).Value.ToString, font1, PrintColor, PrintPosition)
row1 = row1 + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col2, row2)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(3).Value.ToString, font1, PrintColor, PrintPosition)
row2 = row2 + 30
Next
Dim format1 As New StringFormat(StringFormatFlags.NoClip)
Dim format2 As New StringFormat(format1)
format1.LineAlignment = StringAlignment.Near
format1.Alignment = StringAlignment.Center
format2.LineAlignment = StringAlignment.Center
format2.Alignment = StringAlignment.Far
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col3, row3)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(4).Value.ToString, font1, PrintColor, PrintPosition, format2)
row3 = row3 + 30
Next
For z = 0 To DataGridView3.Rows.Count - 2
PrintPosition = New PointF(col4, row4)
e.Graphics.DrawString(DataGridView3.Rows(z).Cells(6).Value.ToString("0.00"), font1, PrintColor, PrintPosition, format2)
row4 = row4 + 30
Next
e.Graphics.DrawString(line.ToString, font1, Brushes.Black, 30, 950) 'เส้นคั่น
e.Graphics.DrawString(tot.ToString, font1, Brushes.Black, 520, 1000)
e.Graphics.DrawString(sum.ToString, font1, Brushes.Black, 640, 1000)
e.Graphics.DrawString(bath.ToString, font1, Brushes.Black, 750, 1000)
e.Graphics.DrawString(c1.ToString, font1, Brushes.Black, 80, 1050)
e.Graphics.DrawString(c2.ToString, font1, Brushes.Black, 85, 1110)
End Sub