Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. PrintPreviewDialog

PrintPreviewDialog

Scheduled Pinned Locked Moved C#
questioncss
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    brain2cpu
    wrote on last edited by
    #1

    I have two problems. The more important: how can I know if the user did hit the Print button or just saw the preview and close the window; the best whould be to close the dialog after the user press the Print button and let me know about this (return ... , delegate, event,...) The other: how can I set the zoom? Default the dialog is very small, I managed to increase it's size but the zoom is still less then 100% and the text is not readable; I can not find anything related to zoom

    R 1 Reply Last reply
    0
    • B brain2cpu

      I have two problems. The more important: how can I know if the user did hit the Print button or just saw the preview and close the window; the best whould be to close the dialog after the user press the Print button and let me know about this (return ... , delegate, event,...) The other: how can I set the zoom? Default the dialog is very small, I managed to increase it's size but the zoom is still less then 100% and the text is not readable; I can not find anything related to zoom

      R Offline
      R Offline
      Reinier van de Wetering
      wrote on last edited by
      #2

      I got this code a couple of days ago of the discussion boards, it worked for me. foreach (Control c in this.printPreviewDialog1.Controls) { if (c is PrintPreviewControl) { ((PrintPreviewControl)c).Zoom = 0.75; } } Don't know about the print button.

      H 1 Reply Last reply
      0
      • R Reinier van de Wetering

        I got this code a couple of days ago of the discussion boards, it worked for me. foreach (Control c in this.printPreviewDialog1.Controls) { if (c is PrintPreviewControl) { ((PrintPreviewControl)c).Zoom = 0.75; } } Don't know about the print button.

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        I'm the one that originally posted that, and you could do the same thing for the print button. Just cycle through the controls (or even using the same code above) and if the control is a Button and has the right properties (if you're developing localized applications, don't check the Text property), and add an EventHandler to the ClickEvent. Honestly, though, the best think you could do is check the DialogResult returned from PrintPreviewDialog.ShowDialog (inherited from CommonDialog). If everything is set up correctly in the PrintPreviewDialog constructor, closing the form with the Close button (the X) should return DialogResult.Cancel, while doing anything else should return a different result. Just get the return value and put a breakpoint there to see what's returned. When possible, don't rely on hacks like I mentioned for finding the Zoom property of the hosted PrintPreviewControl.

        Microsoft MVP, Visual C# My Articles

        B 1 Reply Last reply
        0
        • H Heath Stewart

          I'm the one that originally posted that, and you could do the same thing for the print button. Just cycle through the controls (or even using the same code above) and if the control is a Button and has the right properties (if you're developing localized applications, don't check the Text property), and add an EventHandler to the ClickEvent. Honestly, though, the best think you could do is check the DialogResult returned from PrintPreviewDialog.ShowDialog (inherited from CommonDialog). If everything is set up correctly in the PrintPreviewDialog constructor, closing the form with the Close button (the X) should return DialogResult.Cancel, while doing anything else should return a different result. Just get the return value and put a breakpoint there to see what's returned. When possible, don't rely on hacks like I mentioned for finding the Zoom property of the hosted PrintPreviewControl.

          Microsoft MVP, Visual C# My Articles

          B Offline
          B Offline
          brain2cpu
          wrote on last edited by
          #4

          I tried to get the DialogResult but hitting the Print does not close the dialog, so after printing the user will close the dialog so I'll get Cancel

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups