print a form vb.net

rockwell

Active member
Joined
Dec 6, 2005
Messages
36
Programming Experience
Beginner
Hello all, i was wondering how do we print a form using some event in vb.net. I mean the code to print it out.

Thanks for your time ....
--kris
 
This is working but its chopping off some part of the form and also the alt is not working, only the print screen is being called. Is there a way to fit the form to the size of a paper, may be shrink it ans then print it. Is it possible in vb.net

Thanks again for your reply ..
 
i know it's possible, but you would need to modify that code module, and i dont know where to begin doing this either, as you can guess i'm not the one who made anything in that .vb file i simply uploaded it here for easy access to these questions

perhaps when i get some time next week here i'll look into it and make a better printform function
 
EDIT: Some code suggestions for auto-landscape and auto-scale first posted here. See post below for my re-write of the full module.
 
Last edited:
hello guys thanks for your reply, the alt prtscr is not working for me ....

by the way i was wondering if there is a way to ocnvert the form to either a document or pdf and print it then ....

Thanks again ..
 
I got digging into that PrintForm module yesterday, and besides providing auto-landscape and auto-scale I could not stop , so I added optional page center X/Y and also cleaned out some code that was annoyingly unnecessary in my opinion. So for those interested, here it is attached as zip, PrintForm revisited :)
JuggaloBrotha, you've been advertising it in your signature for some time, do have a look and make the switch if you like.
 

Attachments

  • FormUtilities.zip
    1.8 KB · Views: 122
Last edited:
Hi, the code works perfectly but the only problem is its making the application too slow and its taking too much time to run ...

Any suggestions to make the application run fast ...

--kris
 
rockwell, I didn't think it was slow before, and there is nothing in there that makes your application otherwise run slow. But I still found a small speed improvement and updated the file.
 
hey john, i have a small problem with printing the form now, the alt prtscr is not working all the time, some time the taskbar gets displayed and sometime it doesnt, is there a way to avoid it ....

--kris
 
Alt-PrtScrn is a system hotkey to capture to clipboard the active window. If taskbar is activated, then this is the active window that will be captured when the hotkey is sent. I don't understand how you could have managed to activate the taskbar before running the PrintForm method from that module.
 
I mean taskbar is not the only one getting displayed but the form window too, whats happening is some times the form window with the task bar is displayed and sometimes its not, i guess this gets controlled using

SendKeys.SendWait("%{PRTSC}")

but i dont knwo why some times it gets displayed and sometimes its not .....

i hope i explained it correctly ..

--kris
 
Hi, the printform works perfectly fine now, but i got to give the user an option to select a printer and so i did

If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintForm(Me)
End If

There are two flaws with this,
1) the printer which the user selects is not selected, only the default printer which is set in the printer options in control panel is used

2) the print window which asks for a selection when pressed "ok" doesnt close quickly and when the application takes the screen shot it prints a part of the printer window too ....

any suggestions to get rid of these problems

Thanks for your time ......
 
Back
Top