Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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 25-Jan-13 17:07pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v4
Comments
Abhishek Pant at 26-Jan-13 3:44am
   
"Sorry, the item you requested could not be found."-link not valid
Sergey Alexandrovich Kryukov at 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 at 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 at 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 at 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
Abhishek Pant at 27-Jan-13 2:17am
   
nice link.

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 460
1 Sergey Alexandrovich Kryukov 336
2 Shai Vashdi 294
3 OriginalGriff 280
4 Abhinav S 160
0 Sergey Alexandrovich Kryukov 9,185
1 OriginalGriff 5,315
2 Peter Leow 4,040
3 Maciej Los 3,535
4 Abhinav S 3,308


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 27 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid