I have used this routine in 2 other places successfully but when I try to use it in form3 I am getting the following error message
BC30456 printdoc1_printpage is not a member of Form3. I added the Print Document1 control on my form3 and have added Imports System.Drawing.Printing on top of my code in form3. Following are the 2 subs I use along with the error squiggly line under Me.printdoc1_PrintPage
Private img As Image
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'prints whatever is on the blackboard
img = Me.PictureBox1.Image
Dim printdoc1 As PrintDocument = New PrintDocument
AddHandler printdoc1.PrintPage, AddressOf Me.printdoc1_PrintPage
Dim previewdlg As PrintPreviewDialog = New PrintPreviewDialog
previewdlg.Document = printdoc1
previewdlg.ShowDialog()
End Sub
Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim pageBounds As Rectangle = e.PageBounds
Dim nFactor As Single = CSng(pageBounds.Width / img.Width)
Dim nNewHeight = img.Height * nFactor
pageBounds.Height = CInt(nNewHeight)
e.Graphics.DrawImage(img, New Rectangle(New Point(), pageBounds.Size), New Rectangle(New Point(), img.Size), GraphicsUnit.Pixel)
End Sub
On form3 I have panel1 and inside of panel1 I have picturebox1 and this is where my image is. Just trying to give you oas much info I can provide to help you.
Thanks in advance
Les