请问关于vb.net打印的有关问题
请教关于vb.net打印的问题
最近正在学习vb.net,试着写了一个打印练习程序,如下:
Public Class printcontrol
Private conn As String = "Provider=SQLOLEDB.1;Password=810628;Persist Security Info=True;User ID=sa;Initial Catalog=成本核算;Data Source=caiwu11\FINANCE"
Private rowPage As Integer = 0
Private Sub PrintDocument1_PrintPage1(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim startX As Integer = 150, startY As Integer = 120
Dim strSql As String = "select top 40 款号,成本,数量,类型 from 成本表 "
Dim tb As DataTable = DbOperation.DBOperate(strSql, conn)
Dim dbRow As DataRow
Dim rowCount As Integer
Dim rowsInperpage As Integer = 18
Dim fontBold As New Font("宋体", 15, FontStyle.Bold)
Dim r As Integer = tb.Rows.Count
e.Graphics.DrawString("款号", fontBold, Brushes.Black, startX, startY)
e.Graphics.DrawString("成本", fontBold, Brushes.Black, startX + 150, startY)
e.Graphics.DrawString("数量", New Font("宋体", 15, FontStyle.Bold), Brushes.Black, startX + 300, startY)
e.Graphics.DrawString("类型", New Font("宋体", 15, FontStyle.Bold), Brushes.Black, startX + 450, startY)
startY = startY + 50
For rowCount = rowPage * rowsInperpage To IIf((rowPage + 1) * rowsInperpage > (r - 1), (r - 1), (rowPage + 1) * rowsInperpage)
dbRow = tb.Rows(rowCount)
e.Graphics.DrawString(tb.Rows(rowCount)("款号"), New Font("宋体", 10), Brushes.Black, startX, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("成本"), New Font("宋体", 10), Brushes.Black, startX + 150, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("数量"), New Font("宋体", 10), Brushes.Black, startX + 300, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("类型"), New Font("宋体", 10), Brushes.Black, startX + 450, startY)
startY = startY + 50
Next
rowPage += 1
If r > rowCount + 1 Then
最近正在学习vb.net,试着写了一个打印练习程序,如下:
Public Class printcontrol
Private conn As String = "Provider=SQLOLEDB.1;Password=810628;Persist Security Info=True;User ID=sa;Initial Catalog=成本核算;Data Source=caiwu11\FINANCE"
Private rowPage As Integer = 0
Private Sub PrintDocument1_PrintPage1(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim startX As Integer = 150, startY As Integer = 120
Dim strSql As String = "select top 40 款号,成本,数量,类型 from 成本表 "
Dim tb As DataTable = DbOperation.DBOperate(strSql, conn)
Dim dbRow As DataRow
Dim rowCount As Integer
Dim rowsInperpage As Integer = 18
Dim fontBold As New Font("宋体", 15, FontStyle.Bold)
Dim r As Integer = tb.Rows.Count
e.Graphics.DrawString("款号", fontBold, Brushes.Black, startX, startY)
e.Graphics.DrawString("成本", fontBold, Brushes.Black, startX + 150, startY)
e.Graphics.DrawString("数量", New Font("宋体", 15, FontStyle.Bold), Brushes.Black, startX + 300, startY)
e.Graphics.DrawString("类型", New Font("宋体", 15, FontStyle.Bold), Brushes.Black, startX + 450, startY)
startY = startY + 50
For rowCount = rowPage * rowsInperpage To IIf((rowPage + 1) * rowsInperpage > (r - 1), (r - 1), (rowPage + 1) * rowsInperpage)
dbRow = tb.Rows(rowCount)
e.Graphics.DrawString(tb.Rows(rowCount)("款号"), New Font("宋体", 10), Brushes.Black, startX, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("成本"), New Font("宋体", 10), Brushes.Black, startX + 150, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("数量"), New Font("宋体", 10), Brushes.Black, startX + 300, startY)
e.Graphics.DrawString(tb.Rows(rowCount)("类型"), New Font("宋体", 10), Brushes.Black, startX + 450, startY)
startY = startY + 50
Next
rowPage += 1
If r > rowCount + 1 Then