Results 1 to 2 of 2

Thread: Print preview error

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11

    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.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width