Results 1 to 5 of 5

Thread: [RESOLVED] [2008]How can I prevent from the user to print from PrintPreviewDialog

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    Resolved [RESOLVED] [2008]How can I prevent from the user to print from PrintPreviewDialog

    Hi,

    I am using the code below:
    Code:
            Dim PPD As New PrintPreviewDialog
            PPD.WindowState = FormWindowState.Maximized
            PPD.Document = PrintDocument1
            PPD.ShowDialog()
    When the PrintPreviewDialog show the Document, the user can print the Document.

    How can I prevent from the user to print from PrintPreviewDialog?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2008]How can I prevent from the user to print from PrintPreviewDialog

    This is a bit confusing.

    You are presenting the print preview dialog to the user, but you don't want the user to use it - is that what is happening here?

    If so, then why are you displaying it in the first place? What is it that you do want the user to do?

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    Re: [2008]How can I prevent from the user to print from PrintPreviewDialog

    Hi,

    I want that the user will print from another place (button), because the program needs to save some data before printing.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2008]How can I prevent from the user to print from PrintPreviewDialog

    The PrintPreviewDialog control contains a ToolStrip which has the printToolStripButton among other ToolStripItems. So what you need to do is to get a reference to the printToolStripButton and set its enable property to false prior to showing the printpreviewdialog. Something like this
    Code:
    For Each ctrl As Control In PrintPreviewDialog1.Controls
                If TypeOf ctrl Is ToolStrip Then
                    For Each item As ToolStripItem In DirectCast(ctrl, ToolStrip).Items
                        If item.Name = "printToolStripButton" Then
                            item.Enabled = False
                        End If
                    Next
                End If
            Next
            PrintPreviewDialog1.Show()

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Posts
    224

    Re: [2008]How can I prevent from the user to print from PrintPreviewDialog

    Hi,

    Great Great Great !!!

    Thank you very much

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