0

I am currently using Power Packs to print my form. And with this line of code, I am able to print the form.

PrintForm1.Form = Me
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
    PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable)

But during print preview, the form is cropped into half because my form is scroll-able. Here is the picture. This is the running application. enter image description here

And this is the print preview. enter image description here

How can I print a report nicely in A4 paper size? I have been searching tutorials online but can't find any good ones. Hope you guys can recommend me a good method to print a report. Either using powerpacks or the normal print controls doesnt matter.

Student
  • 432
  • 2
  • 10
  • 30

1 Answers1

0

Unfortunately, printform can only print the part of your form that is visible the moment you call .print.

What you can do is to :

  1. dock (in the properties, there is a dock parameter) your groupbox
  2. include all of your controls in your groupbox(all your labels)
  3. adjust the anchor so that the controls follow your form when you resize it.

Alternatively, you can use crystal reports instead for PDF reports or Microsoft office interop for an Excel/Word Report.

Malcolm Salvador
  • 1,476
  • 2
  • 21
  • 40
  • Does that mean I need to use only one groupbox? – Student Dec 17 '15 at 01:50
  • Well, yes and no. You can use more, as long as you dock them properly in a manner that makes them all appear inside the form every time the form is re sized. – Malcolm Salvador Dec 17 '15 at 01:55
  • But lets say I have a label which can be a paragraph long. Then will the form still able to scroll down? – Student Dec 17 '15 at 01:57
  • Well, you can write a function that checks for the total count of characters on your control, and send them to a new line when a number of characters have been reached, or you can use a RichTextbox and wordwrap the content – Malcolm Salvador Dec 17 '15 at 02:02
  • The advantage of using a rich textbox is that you can also dock it in it's container, so that when the form is resized, and the richtextbox has WordWrap = true, then the text rearranges along with the form. – Malcolm Salvador Dec 17 '15 at 02:12
  • Let me know if this has helped you. Also, don't forget to upvote or accept an answer that has helped you. – Malcolm Salvador Dec 17 '15 at 02:14
  • No sorry it doesn't solve my issue. I tried richtextbox at first but when it gets too long, the richtextbox has a scrollbar and print form will only print what is seen on the form.. – Student Dec 17 '15 at 02:17
  • How about changing font sizes? You can set it on beginning, or resize it when your form has reached a certain size. – Malcolm Salvador Dec 17 '15 at 02:21
  • When the form label texts gets too long, then the font will be too small to read after print in A4. I prefer for it to print on a next paper but I am not sure how to do it. – Student Dec 17 '15 at 02:23
  • Then, printform isn't the right control you should be using. Use Crystal Reports or Office Interop instead. – Malcolm Salvador Dec 17 '15 at 02:24