01.
Partial
Class
Form1
02.
03.
04.
Private
pf
As
Font =
New
Font(
"MS 明朝"
, 12)
05.
Private
prContext
As
System.Drawing.Graphics
06.
Private
topMargin
As
Integer
07.
Private
leftMargin
As
Integer
08.
09.
10.
11.
12.
Private
Sub
pd_PrintPage(
ByVal
sender
As
System.
Object
, _
13.
ByVal
e
As
System.Drawing.Printing.PrintPageEventArgs)
14.
15.
16.
leftMargin = e.MarginBounds.Left
17.
18.
topMargin = e.MarginBounds.Top
19.
20.
prContext = e.Graphics
21.
22.
23.
prContext.DrawLine( _
24.
Pens.Black, _
25.
leftMargin, _
26.
topMargin, _
27.
leftMargin + (e.PageBounds.Width - 2 * leftMargin), _
28.
topMargin _
29.
)
30.
31.
32.
prContext.DrawLine( _
33.
Pens.Black, _
34.
leftMargin, _
35.
topMargin, _
36.
leftMargin, _
37.
topMargin + (e.PageBounds.Height - 2 * topMargin) _
38.
)
39.
40.
41.
prContext.DrawLine( _
42.
Pens.Black, _
43.
leftMargin + (e.PageBounds.Width - 2 * leftMargin), _
44.
topMargin, _
45.
leftMargin + (e.PageBounds.Width - 2 * leftMargin), _
46.
topMargin + (e.PageBounds.Height - 2 * topMargin) _
47.
)
48.
49.
50.
prContext.DrawLine( _
51.
Pens.Black, _
52.
leftMargin, _
53.
topMargin + (e.PageBounds.Height - 2 * topMargin), _
54.
leftMargin + (e.PageBounds.Width - 2 * leftMargin), _
55.
topMargin + (e.PageBounds.Height - 2 * topMargin) _
56.
)
57.
58.
PrString(10, 100,
"日本語表示"
)
59.
PrString(1, 0,
"日本語表示"
)
60.
61.
62.
63.
e.HasMorePages =
False
64.
65.
66.
End
Sub
67.
68.
69.
70.
71.
Private
Sub
PrString(
ByVal
row
As
Integer
,
ByVal
x
As
Integer
,
ByVal
str
As
String
)
72.
73.
Dim
yPos
As
Integer
= 0
74.
75.
yPos = topMargin + (row - 1) * pf.GetHeight(prContext)
76.
77.
prContext.DrawString(str, pf, Brushes.Black, leftMargin + x, yPos)
78.
79.
End
Sub
80.
81.
End
Class