easy one...need to print picturebox

  • Thread starter Thread starter george hardy
  • Start date Start date
G

george hardy

on my form in vs2005, i have a PrintPreviewDialog1, PrintDocument1 and
PictureBox1

all i want to do is print the image i have in Picturebox1 through the
PrintPreview control.

does someone have a code snippet that accomplishes this?

thanks!
gh
 
george hardy said:
on my form in vs2005, i have a PrintPreviewDialog1, PrintDocument1 and
PictureBox1

all i want to do is print the image i have in Picturebox1 through the
PrintPreview control.

In the 'PrintDocument' object's 'PrintPage' event you can use
'e.Graphics.DrawImage(Me.PictureBox1.Image, ...)' to draw the image onto the
print document.
 
cool. that's just what i needed to get started...printing now! didn't
realize it was pinned to the event.

thanks!
 
on my form in vs2005, i have a PrintPreviewDialog1, PrintDocument1 and
PictureBox1

all i want to do is print the image i have in Picturebox1 through the
PrintPreview control.

does someone have a code snippet that accomplishes this?

thanks!
gh

George,
Try this and let us know:

Private Sub PrintImage(ByVal sender As Object,_
ByVal ev As PrintPageEventArgs)

ev.Graphics.DrawImage(Image.FromFile(<filepath>),_
ev.Graphics.VisibleClipBounds)
' If no more page
ev.HasMorePages = False

End Sub

Then call PrintImage subroutine.

Hope this helps, it'll be useful also for me if it works.
 
Back
Top