绘画到成型然后到打印机

发布于 2024-10-17 18:22:09 字数 417 浏览 3 评论 0原文

我经常发现自己需要创建不能与 Crystal Reports 或报表查看器一起使用的自定义报表。我经常将 DataTable 组合在一起并将其转储到 DataGridView 控件中。它从来都不漂亮,而且打印也很困难。

我需要的是一个可以使用 OnPaint 事件调用的类,但直到现在我还没有坐下来编写所有的 Pen 和 Brush 命令。

绘制到屏幕和绘制到打印机都使用 Graphics 对象,因此我想构建一个类,将其传入 Graphics 对象、我的窗口边界(矩形)和一些数据(以实例的形式)我班级的),我用它来绘制表格或一张纸。

这听起来是一个很棒的概念!

当然,以前有人做过类似的事情。

有谁知道这方面的书籍、网站教程或视频吗?

如果有人想在这里为我写下所有内容,那么您将拥有更多权力 - 但我认为这工作量太大了。

I often find myself needing to create custom reports that do NOT work with Crystal Reports or Report Viewer. Often, I hack a DataTable together and dumping that into a DataGridView control. It is never pretty, and printing is difficult.

What I need is a class that I can call using the OnPaint event, but I've never sat down and written all of the Pen and Brush commands until now.

Painting to the screen and painting to a printer both use the Graphics object, so I want to build a class that I'd pass in the Graphics object, my window bounds (a Rectangle), and some data (in the form of an instance of my class) that I'd use to paint a form or a sheet of paper.

That sounds like a great concept!

Surely, someone has done something like this before.

Does anyone know of a book, a website tutorial, or video that goes into this?

If someone wants to write all that out for me here, more power to you - but I'd think that would be too much work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

春夜浅 2024-10-24 18:22:09

如何使用 iText(免费开源 PDF 库 - http://itextpdf.com/)而不是生成 PDF 文档图形对象?然后用户就可以得到一份数字报告而不是纸质报告,更加环保一点......

How about generating a PDF document using iText (free open source PDF library - http://itextpdf.com/) instead of the graphics object? Then the user can have a digital report instead of a paper one, a little bit more environment friendly...

回眸一笑 2024-10-24 18:22:09

我最终使用 PrintPreview 对话框并将所有内容写入 OnPaint 事件中。

一旦完成,我就完全放弃了表格。一个 PrintPreview 实际上是我的客户在直接使用打印机之前查看的表单。

仅供参考:在页面上定位每个项目非常乏味。

I wound up going with a PrintPreview dialog box and writing everything in the OnPaint event.

Once that was done, I completely ditched the form. One PrintPreview that actually serves as the form for my Clients to view before going straight to the printer.

FYI: Positioning every item on the page was tedious.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文