将页眉和页脚添加到 Printing.PrintDocument (.Net 2.0) 的最简单方法?
在实用上或在设计时向 .Net PrintDocument 对象添加页眉和页脚的最简单方法是什么?
具体来说,我正在尝试打印第 3 方网格控件(Infragistics GridEx v4.3),该控件采用 PrintDocument 对象并将自身绘制到其中。
生成的页面仅包含网格及其内容 - 但是我想添加一个页眉或标题来标识打印的报告,可能还添加一个页脚来显示谁打印了它,何时打印,最好是页码和总页数。
我正在使用 VB.Net 2.0。
感谢您的帮助!
What's the easiest way to add a header and footer to a .Net PrintDocument object, either pragmatically or at design-time?
Specifically I'm trying to print a 3rd party grid control (Infragistics GridEx v4.3), which takes a PrintDocument object and draws itself into it.
The resulting page just contains the grid and it's contents - however I would like to add a header or title to identify the printed report, and possibly a footer to show who printed it, when, and ideally a page number and total pages.
I'm using VB.Net 2.0.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关注 booji-boy 的答案,这就是我想到的(出于示例目的,我对其进行了简化):
我必须使用
e.PageBounds.Height - x
的值来获得绘制的项目要排队。再次感谢 Booji Boy 的指点 - 获取 ReportPage.Graphics() 正是我所追求的:o)
Following booji-boy's answer, here's what I came up with (which I've simplified for example purposes):
I had to play with the values of
e.PageBounds.Height - x
to get the drawn items to line up.Thanks again Booji Boy for the pointer - getting at the ReportPage.Graphics() was exactly what I was after :o)
printdocument 对象为要打印的每一页触发 printpage 事件。 您可以使用 printpageeventargs 事件参数将文本/线条/等绘制到打印队列中:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx
当您将其传递到网格时将其调暗,以便您可以处理事件。
The printdocument object fires the printpage event for each page to be printed. You can draw text/lines/etc into the print queue using the printpageeventargs event parameter:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx
Dim it WithEvents when you pass it to the grid, so you can handle the event.