Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get printdocument to print controls on form

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
US
hi

I was woundering if you can use printdocument control to print out all your controls on your form.

For example if I have a button on my form it would print out the button control right where it is on my form
 
No, the printdocument control is used to print DOCUMENTS. The form is not a document. In order to print the form, you need to find some way to capture the screen, then print it.
 
Well what can I use to make it into a document

I am designing a form for clients to fill out and print

I was doing research and was thinking of using crystal reports but not sure how to set it up on vs.net do I need to buy a seperate program for it or does it come with vs.net already.

Thanks
 
Why does the form need to be represented as controls on the screen? Can't you just make a PrintDocument and use PrintPreview if they want to view it before actually printing it out? Or draw the graphics onto your form which you would use to construct the PrintDocument.
 
Hi RiverGuy

I am kind of new to vb.net

But from what I have experienced with PrintDocument and PrintPreview I am not able to print what is on my form.

I am able to set it up so that I could print the contents of what ever is in the textboxes but I need to have it print up the same way the form is viewed on the screen.
 
Well, thats your preference. There are some tutorials out there on how to do the screen capture thing. Just do a search on google for it.

As far as Crystal Reports, that will basically do what I was suggesting--not printing out a picture of a computer screen, but printing out an easily readable document of what has been entered by the user.
 
I have tried the screen shot code it works fine but the problem is if the users screen setting is too big and cuts the form off then the form will be printed with the form being cut off. I need it so if the whole form can not be visible with out scrolling and the user prints the form I would need the whole printed and not just the part that is viewable.
 
Well that's why it won't work. You can't, AFAIK, capture something that does not exist.

That is exactly the reasoning behind "drawing" your own "form" with a PrintDocument.

Again, I don't see why it matters that you draw the text from your TextBoxes and Labels onto a PrintDocument rather than printing out a picture of the TextBoxes and Labels. You can even draw borders around them that make them look like controls if you want. Really, when you think about it, when you buy something at Best Buy, the receipt doesn't look like a picture of their computer screen.
 
I understand but I am going by what my bosses want
I will try out the draw method

thanks for your help
 
Once a form is completed are you saving the data to a file or database? If so, then in crystal reports, add the fields from the database and print.

You might want to find a copy of 'Crystal Reports for Visual Studio .Net', 2nd edition from Wrox. It will take you thru the steps of how to create your report and print it.

Even if you aren't using adatabase to hold customer info, you can capture the info to a file and use that file as a data source in crystal reports.

Or does your client want to see a "form" as part of the printed document. If this is the case, I'd try to talk them out of it, as it isn't neccessary, doesn't look professional and can be a waste of toner or ink to print all those buttons, frames, etc.

BTW Crystal Reports .net is included with VS .net 2003.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top