Click here to Skip to main content
14,580,612 members
Rate this:
Please Sign up or sign in to vote.
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.
Rate this:
Please Sign up or sign in to vote.

Solution 1

There is a code project article on this

Printing a DataGridView on DotNet Framework[^]
   
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.......
Rate this:
Please Sign up or sign in to vote.

Solution 2

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[^]
   
Comments
rajesh102011 17-Oct-11 2:55am
   
thank you

but i want to print content of form in Windows Form(Windows Application in c#)
Rate this:
Please Sign up or sign in to vote.

Solution 3

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>
   
Comments
rajesh102011 17-Oct-11 2:58am
   
thank you,

sir/ma'm I want to printing content of windows form(Windows Applicatio in c#)
Rate this:
Please Sign up or sign in to vote.

Solution 4

   
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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100