Click here to Skip to main content
15,893,266 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI all,

I would like to print data in vb.net some from datagridview, some from label,some from textbox and some from letter header, anyone has idea?, much appreciate in advance.
Posted

1 solution

First of all, printing the control is not such a good idea, because it would violate the isolation between data and presentation. If printing and the loop of UI could be identical in all cases, it would be find, but usually, this is not the case.

For example, imaging you print some check boxes. What, someone should click them on paper? Printed presentation is usually somewhat different from the on-screen UI. The media is very different. Print is arranges on the piece of paper, which is very different from screen.

Therefore, it's always good to isolate data layer, or data model. In this case, you can print and present data from the same data layer, but not print from scree.

Basically, use the class PrintDocument:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[^].

You will find a very clear code sample at the end of the help page referenced above.

—SA
 
Share this answer
 
v4
Comments
Abhishek Pant 26-Jan-13 3:44am    
"Sorry, the item you requested could not be found."-link not valid
Sergey Alexandrovich Kryukov 26-Jan-13 5:03am    
Damn, somebody is removing valid content, once in a while. And this time, with my answer. :-(
Thank you very much for the note, Abhishek.
—SA
Abhishek Pant 27-Jan-13 1:50am    
That profile has been deleted so the answer for that question has been deleted.see profile from your post link-this[^]
Sergey Alexandrovich Kryukov 27-Jan-13 1:57am    
Oh, really? I did no realize it would be done on my post. I actually did not expect people to really vote for ban.. I did not know that question posts, even answered, are also deleted.
Thank you,
—SA
Sergey Alexandrovich Kryukov 27-Jan-13 2:09am    
OK, I hope my new answer is even better than the deleted one. Want to take a look :-)
Thank you,
—SA
















Thank you,
—SA

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