|
-
February 3rd, 2009, 11:42 AM
#1
Printing and print preview Image problems
I'm having problem with the print preview of image in a picturebox. The print preview dialog appears but with a plain white page only. Does anyone know what the problem is?
Also how would i incorporate the page settings feature when i click on "print". So that instead of just printing the image straight away it would show the page settings dialog so I could choose the printer to print from or change the page settings.
The code i'm using is below:
Code:
Private Sub PrintToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintToolStripMenuItem.Click
Try
AddHandler PrintDocument1.PrintPage, AddressOf OnPrintPage
PrintDocument1.Print()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub OnPrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
e.Graphics.DrawImage(PictureBox1.Image, 0, 0)
End Sub
Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
Try
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any help would be much appreciated!
THANKS! =)
-
February 4th, 2009, 10:14 AM
#2
Re: Printing and print preview Image problems
Hi,
You need to add handler to PrintPage event for print preview also. Maybe the best thing would be to move it to New or Form_Load.
As for print settings, check PrintDialog control.
-
February 7th, 2009, 09:45 AM
#3
Re: Printing and print preview Image problems
thanks for your reply
could you further explain "add handler to PrintPage event for print preview also" please?
-
February 7th, 2009, 01:37 PM
#4
Re: Printing and print preview Image problems
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|