简体   繁体   English

VB.NET中带有DataGridView的Form.Print()

[英]Form.Print() with DataGridView in VB.NET

I am printing invoices in my program by launching a form which I styled and which does automatically print itself onLoad by using Form.Print() method. 我将通过启动一个样式设置的表单来打印程序中的发票,该表单会使用Form.Print()方法自动在onLoad上自行打印。

Now this is working great but I have placed a DataGridView inside that form which does contain the order description (items list) to be printed on the invoice. 现在,这很好用,但是我将DataGridView放置在该表单中,该表单确实包含要在发票上打印的订单描述(项目列表)。 This is working now but the DataGridView has a specific height and if I have many items in my order I need the DataGridView (and the form) to automatically adjust its height to show all the items on the invoice. 现在可以使用,但是DataGridView具有特定的高度,如果我的订单中有很多项目,则需要DataGridView(和表单)自动调整其高度以显示发票上的所有项目。

I am not sure how to expand the DataGridView in height, and is it the right way to print an invoice in my program? 我不确定如何扩展DataGridView的高度,这是在程序中打印发票的正确方法吗?

I don't want to use crystal reports because I am generating a QR Code at the bottom of the form so the cashier can scan it. 我不想使用水晶报表,因为我在表格底部生成了QR码,以便收银员可以对其进行扫描。

At last I went with PrintDocument instead of PrintForm. 最后,我选择了PrintDocument而不是PrintForm。

My only concern was that I wanted to layout the document to print with images and tables, and it turned out that the best way to do it, is to create a Word Document inside VB.NET and manipulate the data in it then print that document. 我唯一担心的是,我想对文档进行布局以使其与图像和表格一起打印,事实证明,做到这一点的最佳方法是在VB.NET中创建Word文档并处理其中的数据,然后打印该文档。

Thanks for people who commented on my question and helped me figure it out. 感谢那些对我的问题发表评论并帮助我解决问题的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM