极品分享

教程:收藏学习的一段打印单据的VB.NET代码

Private Sub PD_Print_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PD_Print.PrintPage
Dim wk_Date As String = ToJPDate(Today.Date.ToString().Replace("/", ""))
Dim j As Integer

e.Graphics.DrawString("住所一覧", New Font("MS 明朝", 18, FontStyle.Bold), Brushes.Black, 325, 50)

e.Graphics.DrawString("頁", New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 770, 60)
For i = 0 To me_PrintPage.ToString().Length - 1
e.Graphics.DrawString(me_PrintPage.ToString().Substring(me_PrintPage.ToString().Length - 1 - i, 1), _
New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 760 - 10 * i, 60)
Next
e.Graphics.DrawString(ReseIniFile.CMN_NgoNM(GetNengoFromAD(Today.Date.ToString().Replace("/", ""))) & wk_Date.Substring(0, 2) & "年" & wk_Date.Substring(2, 2) & "月" & wk_Date.Substring(4, 2) & "日", _
New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 630, 80)


e.Graphics.DrawRectangle(Pens.Black, 10, 120, 80, 30)
e.Graphics.DrawString("コード", New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 15, 125)


e.Graphics.DrawRectangle(Pens.Black, 90, 120, 100, 30)
e.Graphics.DrawString("〒", New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 125, 125)


e.Graphics.DrawRectangle(Pens.Black, 190, 120, 600, 30)
e.Graphics.DrawString("住所", New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 193, 125)
If me_PrintPage * 30 < me_DataTable.Rows.Count Then
For i = 30 * (me_PrintPage - 1) To 30 * me_PrintPage - 1


e.Graphics.DrawRectangle(Pens.Black, 10, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 80, 30)
For j = 0 To me_DataTable.Rows(i).Item(0).ToString().Length - 1
e.Graphics.DrawString(me_DataTable.Rows(i).Item(0).ToString().Substring(me_DataTable.Rows(i).Item(0).ToString().Length - 1 - j, 1), _
New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 70 - 10 * j, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
Next


e.Graphics.DrawRectangle(Pens.Black, 90, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 100, 30)
e.Graphics.DrawString(me_DataTable.Rows(i).Item(1).ToString(), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 100, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)


e.Graphics.DrawRectangle(Pens.Black, 190, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 600, 30)
If me_DataTable.Rows(i).Item(2).ToString().Length > 28 Then
e.Graphics.DrawString(me_DataTable.Rows(i).Item(2).ToString().Substring(0, 28), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 193, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
Else
e.Graphics.DrawString(me_DataTable.Rows(i).Item(2).ToString(), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 193, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
End If
Next
e.HasMorePages = True
me_PrintPage = me_PrintPage + 1
Else
For i = 30 * (me_PrintPage - 1) To me_DataTable.Rows.Count - 1


e.Graphics.DrawRectangle(Pens.Black, 10, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 80, 30)
For j = 0 To me_DataTable.Rows(i).Item(0).ToString().Length - 1
e.Graphics.DrawString(me_DataTable.Rows(i).Item(0).ToString().Substring(me_DataTable.Rows(i).Item(0).ToString().Length - 1 - j, 1), _
New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 70 - 10 * j, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
Next


e.Graphics.DrawRectangle(Pens.Black, 90, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 100, 30)
e.Graphics.DrawString(me_DataTable.Rows(i).Item(1).ToString(), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 100, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)


e.Graphics.DrawRectangle(Pens.Black, 190, 150 + (i - 30 * (me_PrintPage - 1)) * 30, 600, 30)
If me_DataTable.Rows(i).Item(2).ToString().Length > 28 Then
e.Graphics.DrawString(me_DataTable.Rows(i).Item(2).ToString().Substring(0, 28), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 193, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
Else
e.Graphics.DrawString(me_DataTable.Rows(i).Item(2).ToString(), New Font("MS 明朝", 14, FontStyle.Regular), Brushes.Black, 193, 150 + (i - 30 * (me_PrintPage - 1)) * 30 + 5)
End If
Next
e.HasMorePages = False
End If
End Sub

2012-04-07 0 /
NET学习
/
标签: 

评论回复

回到顶部