就是打印datagrid里的数据!
解决方案 »
- vb中如何延迟时间
- ____________________________________________菜鸟提问_____________________________________
- winsock的传送问题,高手请进????
- 怎么样提出打印机的低张???
- 〓〓>===→ 风尘鸟,及做过自定义控件的朋友都请进。 路过的朋友,up也给分。100分!
- 求助新增一条记录时出现"运行时错误,多步OLEDB操作,没有操作完成",如何解决?
- 这个Update 语句错到哪儿了?
- 如何调试很长的程序
- 如何用MSO中的COMMANDBAR
- SendMessage的奇怪问题:大侠救命啊!
- Tab控件的使用
- ***************如何根据指定Domain获得所有的网络用户??***************
Dim beginpage, endpage, numcopies, orientation, i
CommonDialog1.CancelError = True
On Error GoTo errhandler
CommonDialog1.ShowPrinter
beginpage = CommonDialog1.FromPage
endpage = CommonDialog1.ToPage
numcopies = CommonDialog1.Copies
orientation = CommonDialog1.orientation
For i = 1 To numcopies
Next
Exit Sub
errhandler:
Exit Sub
end sub
'制定打印位置及分页打印子程序
'需放置一个 MSHFlexGrid 控件 名字设为 Grid1Sub Print1(ByVal sTableHead As String, ByVal iPrintRows As Integer, ByVal iPrintCols As Integer)
Dim StartX As Integer, StartY As Integer, StartX_Const As Integer, StartY_Const As Integer
Dim RowsOfPage As Integer, CurrentPageNo As Integer, CurrentRowsNo As Integer
Dim RowsNo As Integer, ColsNo As Integer
Dim TableWidth As Integer, RowWidth As Integer, ColWidth As Integer
Dim Font As Integer
Dim PageFoot As String'
CurrentPageNo = 1
RowsOfPage = 41 '定义每页行数
StartX = 2100 '定义X方向起始位置
StartX_Const = 2100
StartY = 1400 '定义Y方向起始位置
StartY_Const = 1400
RowWidth = 300 '定义行宽
ColWidth = 1440 '定义列宽
TableWidth = ColWidth * iPrintCols '计算表格总宽度
Font = 10 '
Printer.FontName = "宋体" 'prnt1 4860, 700, 15, sTableHeadPrinter.Line (StartX - 50, StartY - 30)-(StartX - 50 + TableWidth, StartY - 30)
For RowsNo = 0 To iPrintRows - 1
Grid1.Row = RowsNo
StartX = StartX_Const
CurrentRowsNo = CurrentRowsNo + 1
Printer.Line (StartX_Const - 50, StartY - 30 + RowWidth)-(StartX_Const - 50 + TableWidth, StartY - 30 + RowWidth)
For ColsNo = 0 To iPrintCols - 1
Grid1.Col = ColsNo
prnt1 StartX, StartY + 30, Font, Grid1.Text
StartX = StartX + ColWidth
Next ColsNo
If CurrentRowsNo >= RowsOfPage Then
CurrentRowsNo = 0
'以下打印每页中的页脚
PageFoot = "第" + CStr(CurrentPageNo) + "页"
CurrentPageNo = CurrentPageNo + 1
prnt1 StartX - 1000, StartY + RowWidth + 30, 12, PageFoot
StartX = StartX_Const
'以下打印每页中的竖线
For ColsNo = 0 To iPrintCols
Printer.Line (StartX - 50, StartY_Const - 30)-(StartX - 50, StartY + RowWidth - 30)
StartX = StartX + ColWidth
Next ColsNo
'打印下一页
Printer.NewPage
prnt1 4860, 700, 15, sTableHead
StartX = StartX_Const
StartY = StartY_Const
Printer.Line (StartX - 50, StartY - 30)-(StartX + TableWidth - 50, StartY - 30)
For ColsNo = 0 To iPrintCols - 1
prnt1 StartX - 50, StartY + 30, Font, Grid1.TextMatrix(0, ColsNo)
StartX = StartX + ColWidth
Next ColsNo
StartY = StartY + RowWidth
Printer.Line (StartX_Const - 50, StartY - 30)-(StartX_Const - 50 + TableWidth, StartY - 30)
Else
StartY = StartY + RowWidth
End If
Next RowsNo'以下在最后一页剩余划空行
If CurrentRowsNo < RowsOfPage Then
For RowsNo = CurrentRowsNo To RowsOfPage
Printer.Line (StartX_Const - 50, StartY - 30)-(StartX_Const - 50 + TableWidth, StartY - 30)
StartY = StartY + RowWidth
Next RowsNo
End If
'以下打印最后一页中的页脚
PageFoot = "第" + CStr(CurrentPageNo) + "页"
prnt1 StartX_Const + iPrintCols * ColWidth - 1000, StartY - 30 - RowWidth + 30, 12, PageFoot
StartX = StartX_Const
'以下打印最后一页中的竖线
For ColsNo = 0 To iPrintCols
Printer.Line (StartX - 50, StartY_Const - 30)-(StartX - 50, StartY - RowWidth - 30)
StartX = StartX + ColWidth
Next ColsNo
Printer.EndDoc '打印结束
End Sub'打印内容的子程序
Function prnt1(ByVal X As Integer, ByVal Y As Integer, ByVal Font As Single, ByVal txt As String)
Printer.CurrentX = X
Printer.CurrentY = Y
Printer.FontBold = False
Printer.FontSize = Font
Printer.Print txt
End Function'这是做的一个系统的表格打印程序 楼主试试 你只要作相应修改就应该能符合你的要求!!