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:
Any help would be much appreciated!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
THANKS! =)




Reply With Quote