How to make print preview maximized?
-
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
Set
PrintPreviewDialog.DesktopBounds
toScreen.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-----
-
Set
PrintPreviewDialog.DesktopBounds
toScreen.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-----
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
-
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
That weird about the location. Since
Screen.WorkingArea
returns aRectangle
- which includes aPoint
- one would assume that it'd be0, 0
. You can setPrintPreviewDialog.DesktopLocation
tonew Point(0, 0)
instead. As far as the state, for some reasonPrintPreviewDialog
overrides and hides theForm.WindowState
property, even though it derives fromForm
. There might be a valid reason for this, but you could try to setPrintPreviewDialog.WindowState
toFormWindowState.Maximized
. It won't be visible in thePropertyGrid
or code editor, but it's still there (it just gets and setsbase.WindowState
. Hopefully that works.Microsoft MVP, Visual C# My Articles
-
That weird about the location. Since
Screen.WorkingArea
returns aRectangle
- which includes aPoint
- one would assume that it'd be0, 0
. You can setPrintPreviewDialog.DesktopLocation
tonew Point(0, 0)
instead. As far as the state, for some reasonPrintPreviewDialog
overrides and hides theForm.WindowState
property, even though it derives fromForm
. There might be a valid reason for this, but you could try to setPrintPreviewDialog.WindowState
toFormWindowState.Maximized
. It won't be visible in thePropertyGrid
or code editor, but it's still there (it just gets and setsbase.WindowState
. Hopefully that works.Microsoft MVP, Visual C# My Articles
-
That weird about the location. Since
Screen.WorkingArea
returns aRectangle
- which includes aPoint
- one would assume that it'd be0, 0
. You can setPrintPreviewDialog.DesktopLocation
tonew Point(0, 0)
instead. As far as the state, for some reasonPrintPreviewDialog
overrides and hides theForm.WindowState
property, even though it derives fromForm
. There might be a valid reason for this, but you could try to setPrintPreviewDialog.WindowState
toFormWindowState.Maximized
. It won't be visible in thePropertyGrid
or code editor, but it's still there (it just gets and setsbase.WindowState
. Hopefully that works.Microsoft MVP, Visual C# My Articles
Heath is right. The
WindowState
property from Form is still there but hidden by the override. In this case you don't operate on thePrintPreviewDialog
but on the baseForm
. 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(); }