Re: Printing Issue



Hi,

Sample code below. Please note that the exception is thrown when attempting
to show the print preview dialog in its CreateHandle method.

>>

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Try

If dlgPreview.ShowDialog = DialogResult.OK Then

pdocTest.Print()

End If

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try



End Sub

Private Sub pdocTest_PrintPage(ByVal sender As System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles pdocTest.PrintPage

With e.Graphics

..DrawRectangle(Pens.Black, New Rectangle(25, 25, 40, 40))

..DrawString("This is a test document", Me.Font, Brushes.Black, 30, 30)

..DrawEllipse(Pens.Black, 40, 80, 20, 20)

e.HasMorePages = False

End With

End Sub

>>


.