Results 1 to 5 of 5

Thread: Print Preview control :(

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55

    Print Preview control :(

    Hey,

    i really need to use the print preview function so i have assigned a command button so when it clicks it it will load up, but the thing is that nothing will show up. I change the properties (document bit) to the printdocument which i have created to print.

    If anyone understand that can anyone help me?

    thank you

    sorry i am new at visual basic so i cant really go into major depth

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    PrintPreviewDialog

    Hi,

    Dim PPreview As New PrintPreviewDialog()
    PPreview.Document = PrintDocument1
    PPreview.ShowDialog()

    Have a nice day

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Ezpz
    sorry i am new at visual basic so i cant really go into major depth
    I suppose you are talking about Visual Basic.NET which is different than Visual Basic .

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2003
    Posts
    55
    yes sorry visualbasic.net

    and no that code does not bring up items on my print preview

    the code i have used is this:
    VB Code:
    1. Dim WithEvents pdoc As Printing.PrintDocument
    2.     Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage
    3.         e.Graphics.DrawString("Membership Name:  " & dettxtnam.Text, New Font("Tahoma", 14), Brushes.Black, 15, 100)
    4.         e.Graphics.DrawString("Membership Number:" & dettxtnum.Text, New Font("Tahoma", 14), Brushes.Black, 15, 200)
    5.  
    6.         e.Graphics.DrawString("Items List:", New Font("Tahoma", 14), Brushes.Black, 15, 300)
    7.         e.Graphics.DrawString(prodlst.Text, New Font("Tahoma", 14), Brushes.Black, 15, 400)
    8.  
    9.         e.Graphics.DrawString("INVOICE", New Font("Tahoma", 15), Brushes.Black, 15, 500)
    10.         e.Graphics.DrawString("Total Before VAT: " & total.Text, New Font("Tahoma", 14), Brushes.Black, 15, 600)
    11.         e.Graphics.DrawString("VAT:              " & totvat.Text, New Font("Tahoma", 14), Brushes.Black, 15, 700)
    12.         e.Graphics.DrawString("Final TOTAL       " & total1.Text, New Font("Tahoma", 14), Brushes.Black, 15, 800)
    13.  
    14.     End Sub
    15.   Dim PPreview As New PrintPreviewDialog
    16.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    17.         PPreview.Document = PrintDocument1
    18.         PPreview.ShowDialog()
    19.     End Sub



    so what am i doing wrong
    Last edited by Ezpz; Jan 17th, 2004 at 04:29 AM.

  5. #5
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    PrintPreviewDialog

    Hi,

    From the ToolBox drag and drop the PrintDocument1 on your form.

    Name it pDoc like in your program

    Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage
    e.Graphics.DrawString("My Name is yulyos", New Font("Tahoma", 14), Brushes.Black, 15, 100)
    '...
    '...
    '...
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim PPreview As New PrintPreviewDialog()
    PPreview.Document = pDoc
    PPreview.ShowDialog()
    End Sub

    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