|
|
คือผมต้องการให้มันปรับขนาดตามสินค้าที่ถูกเลือกหรือที่ขาย ถ้าสินค้าเยอะก็ยาวตามจำนวนสินค้าอะครับ รบกวนช่วยหน่อยนะครับ ขอบคุณมากครับ
Code (VB.NET)
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
'ใบเสร็จ
Dim column(8) As Integer
column(1) = 10
column(2) = 70
column(3) = 160
column(4) = 320
column(5) = 430
column(6) = 530
column(7) = 120
column(8) = 570
Dim font As New Font("Cordia New", 14, FontStyle.Bold)
Dim font1 As New Font("Cordia New", 18, FontStyle.Bold)
Dim font2 As New Font("Cordia New", 14)
e.Graphics.DrawString("ร้านปัญญารุ่งเรืองการค้า", font1, Brushes.Black, column(1), 20)
e.Graphics.DrawString("โทร : 087-975-5125", font2, Brushes.Black, column(1), 48)
e.Graphics.DrawString("เลขที่ใบเสร็จ : " + frm_productsale.lbl_receipt_no.Text, font2, Brushes.Black, column(1), 69)
e.Graphics.DrawString("วันที่ : " + frm_productsale.lbl_receipt_date.Text, font2, Brushes.Black, column(1), 87)
e.Graphics.DrawString(frm_productsale.lbl_time.Text, font2, Brushes.Black, column(7), 87)
e.Graphics.DrawLine(Pens.Black, column(1), 110, 610, 110)
Dim line As Integer = 120
Dim line1 As Integer = 105
e.Graphics.DrawString("ลำดับ", font2, Brushes.Black, column(1), line)
e.Graphics.DrawString("รหัสสินค้า", font2, Brushes.Black, column(2), line)
e.Graphics.DrawString("รายการสินค้า", font2, Brushes.Black, column(3), line)
e.Graphics.DrawString("จำนวนสินค้า", font2, Brushes.Black, column(4), line)
e.Graphics.DrawString("ราคาสินค้า", font2, Brushes.Black, column(5), line)
e.Graphics.DrawString("ราคารวม", font2, Brushes.Black, column(6), line)
For i As Integer = 0 To frm_productsale.list_view_sale.Items.Count - 1
line += 20
Dim print_out(8) As String
With frm_productsale.list_view_sale
print_out(1) = .Items(i).SubItems(0).Text
print_out(2) = .Items(i).SubItems(1).Text
print_out(3) = .Items(i).SubItems(2).Text
print_out(4) = .Items(i).SubItems(3).Text
print_out(5) = .Items(i).SubItems(4).Text
print_out(6) = .Items(i).SubItems(5).Text
End With
e.Graphics.DrawString(print_out(1), font2, Brushes.Black, column(1), line)
e.Graphics.DrawString(print_out(2), font2, Brushes.Black, column(2), line)
e.Graphics.DrawString(print_out(3), font2, Brushes.Black, column(3), line)
e.Graphics.DrawString(print_out(4), font2, Brushes.Black, column(4), line)
e.Graphics.DrawString(print_out(5), font2, Brushes.Black, column(5), line)
e.Graphics.DrawString(print_out(6), font2, Brushes.Black, column(6), line)
Next
line += 35
e.Graphics.DrawLine(Pens.Black, column(1), line, 610, line)
line += 9
e.Graphics.DrawString("ราคารวม " & frm_productsale.txt_total.Text & "", font, Brushes.Black, column(5), line)
e.Graphics.DrawString("บาท ", font, Brushes.Black, column(8), line)
line += 20
e.Graphics.DrawString("เงินที่รับมา " & txt_receive.Text & "", font, Brushes.Black, column(5), line)
e.Graphics.DrawString("บาท ", font, Brushes.Black, column(8), line)
line += 20
e.Graphics.DrawString("เงินทอน " & txt_change.Text & "", font, Brushes.Black, column(5), line)
e.Graphics.DrawString("บาท ", font, Brushes.Black, column(8), line)
End Sub
Code (VB.NET)
Private Sub printting_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles printting.Click
PrintDocument1.DefaultPageSettings.PaperSize = New System.Drawing.Printing.PaperSize("Custom", 650, 300)
PrintPreviewDialog1.Show()
PrintPreviewDialog1.Document = PrintDocument1
End Sub
Tag : .NET, VBScript
|
|
|
|
|
|
Date :
2017-02-26 22:58:24 |
By :
velonz |
View :
1521 |
Reply :
14 |
|
|
|
|
|
|
|
|
|