vb.net打印控件 vb6打印窗体好的方法

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" '打印的内容

e.Graphics.DrawString(s, stringFont, Brushes.AliceBlue, rectDraw, strFormat)

End Sub

关于vb.net添加打印控件的用法

txt文件:

procedure TForm1.Button1Click(Sender: TObject);

var

MyFile: TextFile;

SourceFile:TextFile;

Tmp:String;

begin

AssignPrn(MyFile);

AssignFile(SourceFile,'FilePath');

Reset(SourceFile);

Rewrite(MyFile);

Readln(SourceFile,Tmp);

While Not EOF(SourceFile) do

Begin

Writeln(MyFile, Tmp);

Readln(SourceFile,Tmp);

System.CloseFile(MyFile);

end;

图形文件需要TPrinter.canvas来打印了,

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

VS2005如何用VB.NET代码实现打印功能

有个PrintDocument控件,可以实现打印。。。

MSDN原话:

使用 PrintDocument 组件

涉及 PrintDocument 组件的两种主要情况是:

简单的打印作业,如打印单个文本文件。在这种情况下,应将 PrintDocument 组件添加到 Windows 窗体,然后在 PrintPage 事件处理程序中添加打印文件的编程逻辑。 该编程逻辑应以使用 Print 方法打印文档结束。

此方法向打印机发送一个 Graphics 对象,该对象包含在 PrintPageEventArgs 类的 Graphics 属性中。

有关如何使用 PrintDocument 组件打印文本文档的示例,请参见

如何:打印 Windows 窗体中的多页文本文件。

更为复杂的打印作业,如想要重新使用已编写的打印逻辑的情况。

在这种情况下,应从 PrintDocument 组件派生一个新组件,并重写

(请参见 Visual Basic 的 重写或 C# 的 重写) PrintPage 事件。

将 PrintDocument 组件添加到窗体后,它出现在 Windows 窗体设计器底部的栏中

网站栏目:vb.net打印控件 vb6打印窗体好的方法
标题链接:https://www.cdcxhl.com/article22/dddgijc.html

成都网站建设公司_创新互联,为您提供用户体验面包屑导航定制开发标签优化动态网站响应式网站

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都网站建设公司