judico
asked on
Printing a Form in VB.NET
Suppose you have a form open on the screen which takes up only a part of it. How can one print this form, i.e. have a screenshot only of the part of the screen where the form is?
ASKER
Thanks for the link. The example, however, doesn't seem to be written in VB.NET.
Hi again,
sorry about that...
get a PrintDocument from the toolBox.
Help on PrintDocument:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDrawingPrintingPrintDocumentClassTopic.asp
Help on Graphic.DrawString:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsclassdrawstringtopic4.asp
-Baan
sorry about that...
get a PrintDocument from the toolBox.
Help on PrintDocument:
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDrawingPrintingPrintDocumentClassTopic.asp
Help on Graphic.DrawString:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdrawinggraphicsclassdrawstringtopic4.asp
-Baan
Double click on the PrintDocument to get to the "PrintDocument1_PrintPage" event handler.
-Baan
-Baan
ASKER
These links also don't seem to solve the problem. It appears that they concern printing of a document and not printing of a screenshot of the form displayed on the screen.
Hi,
have a look at this article
http://www.vb-helper.com/howto_net_print_form_image.html
Hope that this helps you
Regards,
venki
have a look at this article
http://www.vb-helper.com/howto_net_print_form_image.html
Hope that this helps you
Regards,
venki
ASKER
Thanks for the link. For some reason, however, I can't declare PrintDocument1. The following
Private WithEvents m_PrintDocument As PrintDocument1
gives me the error message
Type 'PrintDocument1' is not defined.
despite the fact that I have installed the PrintDocument1 object from the ToolBox. What might be the reason?
Private WithEvents m_PrintDocument As PrintDocument1
gives me the error message
Type 'PrintDocument1' is not defined.
despite the fact that I have installed the PrintDocument1 object from the ToolBox. What might be the reason?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
planocz, this part of your code:
Private Sub pdoc_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.Pr intPageEve ntArgs) Handles pdoc.PrintPage
e.Graphics.DrawImage(memor yImage, 0, 0)
End Sub
gives me the following error:
Handles clause requires a WithEvents variable.
Do you have any suggestions how to fix that?
Private Sub pdoc_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.Pr
e.Graphics.DrawImage(memor
End Sub
gives me the following error:
Handles clause requires a WithEvents variable.
Do you have any suggestions how to fix that?
Sorry I forgot to add this to your FORM...
Private WithEvents pdoc As New PrintDocument
Private WithEvents pdoc As New PrintDocument
ASKER
iboutchkine and planocz,
Thank you so much for the help. I want to give points to both of you. How can I do that?
judico
Thank you so much for the help. I want to give points to both of you. How can I do that?
judico
ASKER
iboutchkine and planocz,
I just sent 250 points to each one of you. Please let me know if there was any problem in receiving the points. Thanks again for the help.
judico
I just sent 250 points to each one of you. Please let me know if there was any problem in receiving the points. Thanks again for the help.
judico
I hope it will help me as well, thats some great work guys. Keep it UP !!
Hi Guys
The above are great if you only want to capture the visible part of the screen - how would you work this if your form was longer than the screen and you used the scrollbar to move down it? ( I have this issue at the moment!)
Regards,
Dave
The above are great if you only want to capture the visible part of the screen - how would you work this if your form was longer than the screen and you used the scrollbar to move down it? ( I have this issue at the moment!)
Regards,
Dave
take alook here:
http://searchvb.techtarget.com/vsnetATEAnswers/0,293820,sid8_gci872552_tax293474,00.html
-Baan