Click here to Skip to main content
15,943,245 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone i just want to know hoe to print form in c# winform. Actually i want to print other form on click of print button. let me explain in detail....
I have two forms i.e. form1 and form2. now on form1 i have given print button and on the click event of this button form2 get printed as simple word page. plz help me out i m in need.....
Posted

If you are attempting to print Form2, I believe this code will work:

http://msdn.microsoft.com/en-us/library/aa287529(v=vs.71).aspx[^]

You will probably need to bring Form2 to the foreground before running that code and you might need to put the actual code in the Form2 code behind.

I would recommend you get the Form printing to work first, and then try to expand it to be called from another form.
 
Share this answer
 
Comments
Member 8233601 14-Jun-12 8:58am    
can u plz tell me step by step procedure...
Tim Corey 14-Jun-12 9:01am    
The link I gave you gives you all the code you need to print a form. Get started there. Once you have your form printing, call the print method from Form1 using a reference to Form2. If that works, you are good to go. If it doesn't, try using the reference to Form2 to bring it to the foreground and then execute the print command.
Sergey Alexandrovich Kryukov 14-Jun-12 15:31pm    
Good link and advice, my 5. I would only note that in many cases the developers think they need to print a form/windows, in reality what's needed is printing some data associated with the form, which is not exactly the same.
--SA
try it
C#
Process printjob = new Process();
printjob.StartInfo.UseShellExecute = true;
printjob.StartInfo.FileName = @"c:/test.jpg";
printjob.StartInfo.Verb = "print";
printjob.StartInfo.CreateNoWindow = true;
printjob.Start();
 
Share this answer
 

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