
正文
vb.net表单打印 vbs打印
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net如何实现打印DataGridView1里的内容,求源码
使用 PrintDocument 控件的 Print() 方法可以打印指定对象中的内容,参考代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(Me.DataGridView1.Width, Me.DataGridView1.Height)
DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
e.Graphics.DrawImage(bm, 0, 0)
End Sub
相关问答
Q1: VB.NET怎么实现打印功能啊 呜呜(
利用 printdocument控件
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim stringFont As New Font("Arial", 16)
Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
Dim strFormat As New StringFormat
Dim s As String
s = "print word" '打印vb.net表单打印的内容
e.Graphics.DrawString(s, stringFont, Brushes.AliceBlue, rectDraw, strFormat)
End Sub
Q2: VS2005如何用VB.NET代码实现打印功能
有个PrintDocument控件,可以实现打印。。。
MSDN原话:
使用 PrintDocument 组件
涉及 PrintDocument 组件的两种主要情况是:
简单的打印作业vb.net表单打印,如打印单个文本文件。在这种情况下vb.net表单打印,应将 PrintDocument 组件添加到 Windows 窗体,然后在 PrintPage 事件处理程序中添加打印文件的编程逻辑。 该编程逻辑应以使用 Print 方法打印文档结束。
此方法向打印机发送一个 Graphics 对象,该对象包含在 PrintPageEventArgs 类的 Graphics 属性中。
有关如何使用 PrintDocument 组件打印文本文档的示例,请参见
如何:打印 Windows 窗体中的多页文本文件。
更为复杂的打印作业,如想要重新使用已编写的打印逻辑的情况。
在这种情况下,应从 PrintDocument 组件派生一个新组件,并重写
(请参见 Visual Basic 的 重写或 C# 的 重写) PrintPage 事件。
将 PrintDocument 组件添加到窗体后,它出现在 Windows 窗体设计器底部的栏中
Q3: vb.net 打印功能
可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。
也可以做成vb报表(VB自带有)。
先设置报表格式,打印时向报表传递数据就可以了。
Q4: VB.NET程序如何实现表格填写和打印
一般情况下先用EXCEL做好一个样表文件,设定好打印区域和样式,需要填内容的时候,先程序复制一个样表文件,然后调用API打开表格填写内容并打印,如果想用API来实现调整模板和打印预览,可能比较困难,而且很抽象,个人觉得费时费力效果还不一定理想
vb.net表单打印的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbs打印、vb.net表单打印的信息别忘了在本站进行查找喔。






