如何在不使用报表的情况下打印页面或如何打印datagrid值 [英] how to print page or how to print datagrid values without using reports

查看:109
本文介绍了如何在不使用报表的情况下打印页面或如何打印datagrid值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想像超市票据一样以小尺寸和A4尺寸打印出来.我不知道如何在vb.net中应用它.如果有人知道,请帮助我.


预先感谢.

Hi Everybody,

I want to take print out like super market bill in small size and A4 size. I dont know how to apply this in vb.net. If anybody know please help me.


Thanks in advance.

推荐答案

1.创建一个页面(print.aspx),其中包含您在打印页面上所需的所有详细信息.

2.在页面上放置一个按钮,然后单击该按钮,只需使用以下代码打开print.aspx页面.

1. Create a page(print.aspx) with all the details you required on printing page.

2. Place a button on the page and onclick of that button simply open the print.aspx page with below code.

<a href="javascript:void(0);" onclick="window.open(''print.aspx?orderID=<%# Container.DataItem("OrderId") %>'','''',''width=100,height=200,scrollbars=1'');">
   </a>



3.在上面的代码片段中,订单ID作为查询字符串传递给print.aspx.目的是按照订单ID
获取打印页面上的所有所需信息.
4.在print.aspx的页面加载中,首先获取所有必需的内容并将其分配给适当的控件,然后只需在页面加载中添加以下行即可.



3. Here in the above code snippest, order id is passed as query string to print.aspx. Purpose of that is to fetch all the needed information on the print page by order id

4. On the page load of print.aspx, first fetch all the required stuff and assign it to appropriate control, then simply add below line in the page load .

ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "print", "window.print();", True)



5.在上一行中,页面加载后,将出现打印对话框,以便用户可以打印该特定页面.

希望对您有所帮助.



5. With the above line, after page load, print dialogue will appear so that use can print that particular page.

Hope it helps.


您需要查看System.Drawing.Printing命名空间,尤其是PrintDocument类.这是MSDN文章 PrintDocument类 [ ^ ].此页面也有一个很好的例子.

希望对您有帮助
You need to look into the System.Drawing.Printing Namespace, specifically the PrintDocument class. Here is a link to the MSDN article PrintDocument Class[^]. This page has a good example as well.

Hope this helps


这篇关于如何在不使用报表的情况下打印页面或如何打印datagrid值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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