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. How to make print preview maximized?

How to make print preview maximized?

Scheduled Pinned Locked Moved C#
tutorialquestion
6 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
    blakeb_1
    wrote on last edited by
    #1

    Does anyone know how to make the print preview dialog open up in a maximized state? It doesn't have a WindowState property, so I'm not really sure what to do. Thanks, Blake

    H 1 Reply Last reply
    0
    • B blakeb_1

      Does anyone know how to make the print preview dialog open up in a maximized state? It doesn't have a WindowState property, so I'm not really sure what to do. Thanks, Blake

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

      Set PrintPreviewDialog.DesktopBounds to Screen.PrimaryScreen.WorkingArea.

      -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

      B 1 Reply Last reply
      0
      • H Heath Stewart

        Set PrintPreviewDialog.DesktopBounds to Screen.PrimaryScreen.WorkingArea.

        -----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----

        B Offline
        B Offline
        blakeb_1
        wrote on last edited by
        #3

        I tried that, but the problem is that it doesn't change the state at all, so the maximize button is still available for clicking. Also, it doesn't seem to position the window correctly either. It makes it the correct size, but it doesn't position at the top of the screen. Is there no possible way to actually change the maximized state and not just the size? Thanks, Blake

        H 1 Reply Last reply
        0
        • B blakeb_1

          I tried that, but the problem is that it doesn't change the state at all, so the maximize button is still available for clicking. Also, it doesn't seem to position the window correctly either. It makes it the correct size, but it doesn't position at the top of the screen. Is there no possible way to actually change the maximized state and not just the size? Thanks, Blake

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

          That weird about the location. Since Screen.WorkingArea returns a Rectangle - which includes a Point - one would assume that it'd be 0, 0. You can set PrintPreviewDialog.DesktopLocation to new Point(0, 0) instead. As far as the state, for some reason PrintPreviewDialog overrides and hides the Form.WindowState property, even though it derives from Form. There might be a valid reason for this, but you could try to set PrintPreviewDialog.WindowState to FormWindowState.Maximized. It won't be visible in the PropertyGrid or code editor, but it's still there (it just gets and sets base.WindowState. Hopefully that works.

          Microsoft MVP, Visual C# My Articles

          B T 2 Replies Last reply
          0
          • H Heath Stewart

            That weird about the location. Since Screen.WorkingArea returns a Rectangle - which includes a Point - one would assume that it'd be 0, 0. You can set PrintPreviewDialog.DesktopLocation to new Point(0, 0) instead. As far as the state, for some reason PrintPreviewDialog overrides and hides the Form.WindowState property, even though it derives from Form. There might be a valid reason for this, but you could try to set PrintPreviewDialog.WindowState to FormWindowState.Maximized. It won't be visible in the PropertyGrid or code editor, but it's still there (it just gets and sets base.WindowState. Hopefully that works.

            Microsoft MVP, Visual C# My Articles

            B Offline
            B Offline
            blakeb_1
            wrote on last edited by
            #5

            I did the WindowState equal to Maximized and its working. Thanks! I just figured since it wasn't in the code editor that it wouldn't work. Blake

            1 Reply Last reply
            0
            • H Heath Stewart

              That weird about the location. Since Screen.WorkingArea returns a Rectangle - which includes a Point - one would assume that it'd be 0, 0. You can set PrintPreviewDialog.DesktopLocation to new Point(0, 0) instead. As far as the state, for some reason PrintPreviewDialog overrides and hides the Form.WindowState property, even though it derives from Form. There might be a valid reason for this, but you could try to set PrintPreviewDialog.WindowState to FormWindowState.Maximized. It won't be visible in the PropertyGrid or code editor, but it's still there (it just gets and sets base.WindowState. Hopefully that works.

              Microsoft MVP, Visual C# My Articles

              T Offline
              T Offline
              Tom Larsen
              wrote on last edited by
              #6

              Heath is right. The WindowState property from Form is still there but hidden by the override. In this case you don't operate on the PrintPreviewDialog but on the base Form. This code seems to do what you want. PrintPreviewDialog ppd = null; try { ppd = new PrintPreviewDialog(); Form wind = ppd as Form; wind.WindowState = FormWindowState.Maximized; ppd.ShowDialog(); } finally { if(ppd != null) ppd.Dispose(); }

              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