在VB.NET中打印多个页面 [英] Print multiple pages in VB.NET

查看:105
本文介绍了在VB.NET中打印多个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打印列表视图,ListView中有太多行,所以我想为所有项目打印更多页面,我该怎么做?



我尝试了什么:



e.HasMorePages但这打印在现有页面上,它不打印到新的纸张。

解决方案

如果您使用的是e.HasMorePages,那么您 - 正确 - 使用PrintDocument。



e.HasMorePages告诉系统,从PrintPage事件处理程序返回后,它应该完成将页面传递给输出,然后引发一个新的PrintPage事件,让你将下一组信息放在一起。

从它的声音来看,你是在循环中设置HasMorePages并期望结束页面输出 - 这不会发生:你需要退出事件处理程序来完成页面。



试试这个非常基本的例子:

  P rivate  pageNo 作为 整数 =  1  

私有 Sub pd_PrintPage( ByVal 发​​件人作为 对象 ByVal ev As PrintPageEventArgs)
ev.Graphics.DrawString(pageNo.ToString(),Font,Brushes.Black, 100 100
pageNo = pageNo + 1
ev.HasMorePages = pageNo< = 3
结束


I am trying to print a List View, there are too many lines in the ListView so I want to print more pages for all the items, how do I do this?

What I have tried:

e.HasMorePages but this prints over the existing page, it does not print to a new sheet of paper.

解决方案

If you are using e.HasMorePages then you are - correctly - using a PrintDocument.

e.HasMorePages tells the system that after you return from the PrintPage event handler, it should finish passing the page to the output and then raise a new PrintPage event to let you put the next set of information together.
From the sound of it, you are setting HasMorePages in a loop and expecting that to end the page out put - that doesn't happen: you need to exit the event handler to finalise the page.

Try this very basic example:

Private pageNo As Integer = 1

Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
    ev.Graphics.DrawString(pageNo.ToString(), Font, Brushes.Black, 100, 100)
    pageNo = pageNo + 1
    ev.HasMorePages = pageNo <= 3
End Sub


这篇关于在VB.NET中打印多个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆