01.
private
void
printDocument1_PrintPage(
object
sender, System.Drawing.Printing.PrintPageEventArgs e)
02.
{
03.
try
04.
{
05.
OleDbConnection con =
new
OleDbConnection(
"Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\\Project\\Visual Studio\\ระบบยืมคืน\\ระบบยืม-คืน.mdb"
);
06.
con.Open();
07.
08.
for
(
int
i = 0; i <= dataGridView1.RowCount - 1; ++i)
09.
{
10.
string
title = dataGridView1.Rows[i].Cells[1].Value.ToString();
11.
int
line = 5;
12.
line += 25;
13.
e.Graphics.DrawString(
"ใบเสร็จแสดงรายการยืม"
,
new
Font(
"TH Sarabun New"
, 16, FontStyle.Bold), Brushes.Black, 0, line);
14.
e.Graphics.DrawString(
"ชื่อ "
+ sname.Text +
"ชั้น"
+ syear +
""
,
new
Font(
"TH Sarabun New"
, 16, FontStyle.Bold), Brushes.Black, 0, line);
15.
e.Graphics.DrawString(
"รายการที่ยืม"
,
new
Font(
"TH Sarabun New"
, 16, FontStyle.Bold), Brushes.Black, 0, line);
16.
}
17.
}
18.
catch
19.
{ }
20.
}