Click here to Skip to main content
15,125,228 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to preview multiple images using print preview and picturebox.. thanks!

by the way this is my code..

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        e.Graphics.DrawImage(IMG1.Image, e.MarginBounds.Left, e.MarginBounds.Top)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PrintPreviewDialog1.PrintPreviewControl.Zoom = 1
        PrintPreviewDialog1.Document = PrintDocument1
    End Sub
Updated 13-Aug-13 4:29am
Sergey Alexandrovich Kryukov 13-Aug-13 10:35am
Why PictireBox? You already use Graphics.DrawImage, do the same in your window.
Member 10163198 13-Aug-13 11:59am
i see your right.. i didn't notice.. my problem is i want to print with the column of 5 and the row 3 with the same image.. just like this..




1 solution

You did not show the code of the form, or the print preview. If you want to use PictureBox, use it (this is the rare case when it would make full sense). I don't see why it could possibly be a problem.

However, if you want print preview close to the print, use the same thing as you already do in the print page, you should override the virtual method System.Windows.Forms.Control.OnPaint or handle the event System.Windows.Forms.Control.Paint. The instance of System.Drawing.Graphics will be passed to you in the event arguments, and you can draw the images, the same way you already do.

Practically, abstract the rendering from media (screen, print, bitmap) by writing a separate method which accepts the same event arguments. Then you can call this method from different places: print page rendering, paint handler (on screen), draw on a bitmap, etc.


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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900