-
Print preview error
I'm trying to Preview before I print and I'm getting this error. Can somebody tell me why.
Code:
Private Sub Preview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Preview.Click
Dim ErrReport As PrintDocument
Dim dlgPreview As PrintPreviewDialog
ErrReport = New PrintDocument()
dlgPreview = New PrintPreviewDialog()
AddHandler ErrReport.PrintPage, AddressOf PrintReport
dlgPreview.Document = ErrReport
dlgPreview.ShowDialog()
End Sub
*** my error
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
PrintReport is where the report is created.
Thanks.
-
Hi,
Imports System.Drawing.Printing
Private Sub Button1_Click...
Dim ppd As New PrintPreviewDialog()
Dim pd As New PrintDocument()
ppd.Document = pd
ppd.ShowDialog()
End Sub
Watch and copy examples of Source Code in VB.NET
[email protected]
http://www.geocities.com/yulyos4vbnet
Have a nice day