Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
Posted
Updated 13-Oct-11 22:26pm
v2
Comments
devildx2050 14-Oct-11 4:38am    
i think its better you can crystal report for your problem.

There is a code project article on this

Printing a DataGridView on DotNet Framework[^]
 
Share this answer
 
Comments
rajesh102011 17-Oct-11 2:52am    
thank you sir,

it is only print content of datagridview, i just want to do to print whole form content like textbox data, label Name, combobox selected item(in Windows Form) it should first previewed then print. etc.......
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[^]
 
Share this answer
 
Comments
rajesh102011 17-Oct-11 2:55am    
thank you

but i want to print content of form in Windows Form(Windows Application in c#)
This works fine for me
XML
<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>
 
Share this answer
 
Comments
rajesh102011 17-Oct-11 2:58am    
thank you,

sir/ma'm I want to printing content of windows form(Windows Applicatio in c#)
 
Share this answer
 
Comments
Anuja Pawar Indore 17-Oct-11 3:24am    
Refer this too
http://www.dreamincode.net/forums/topic/44330-printing-in-c%23/

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900