Maximizing a print preview dialog in c#

Here’s a way to get a print preview dialog (or perhaps any resizeable dialog) maximised.

dlg.Show();
//Make full screen
//cant use WindowState as its not a form
//dlg.DesktopBounds = Screen.FromControl(dlg).WorkingArea;
((Form)dlg).WindowState = FormWindowState.Maximized;
dlg.BringToFront();

Although some times it disappears behind whatever form had focus last.

Update

Looks like the dialog can be cast to a form allowing WindowState to be set.

PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = doc;
((Form)dlg).WindowState = FormWindowState.Maximized;
dlg.ShowDialog();
Bookmark the permalink.

Comments are closed.