如何在C#Windows应用程序中打印包括datagridview内容的表单的整个内容 [英] how to print whole content of form including datagridview content in c# windows application

查看:66
本文介绍了如何在C#Windows应用程序中打印包括datagridview内容的表单的整个内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我在打印包括datagridview内容的整个表单内容时遇到问题.在我的表单中,其他一些详细信息显示在顶部,两个datagridview绑定的数据显示在下面....我想在表单上同时打印datagridview和内容,并查看pdf中的打印预览,然后打印所有内容

例如;名称(Label1)大卫(Textbox1)
添加(标签2)印度(文本框2)

Datagridview1

Datagridview2


....请帮助我.........
谢谢!

hi guys

i have a problem to print whole form content including datagridview content. In my form some other details are present on top and two datagridview binded data is shown in below.......i am wanting to print both datagridview and content on form and see print preview in pdf then print all content

e.g; Name(Label1) David(Textbox1)
add(Label2) India(Textbox2)

Datagridview1

Datagridview2


....please help me.........
Thank You!

推荐答案

在此有一个代码项目文章

在DotNet Framework上打印DataGridView [
There is a code project article on this

Printing a DataGridView on DotNet Framework[^]


尝试以下一项:

将您要打印的所有内容放在div中,并参考以下链接

打印网页的虚拟区域 [
Try this one:

Place all the content what u want to print in a div and refer following link

Print a purticular area of webpage[^]


这对我来说很好
This works fine for me
<script type="text/javascript">
    function printPartOfPage(elementId) {
        var printContent = document.getElementById(elementId);
//this is the id of the div in which the complete content is placed
        var windowUrl = 'Test';
        var uniqueName = new Date();
        var windowName = 'Print' + uniqueName.getTime();
        var printWindow = window.open(windowUrl, windowName, 'left=50,top=50,width=600,height=400');
        printWindow.document.write(printContent.innerHTML);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();
        printWindow.close();
    }</script>


这篇关于如何在C#Windows应用程序中打印包括datagridview内容的表单的整个内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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