|
|
Title | Set the initial size and window state of a PrintPreviewDialog in Visual Basic .NET |
Description | This example shows how to set the initial size and window state of a PrintPreviewDialog in Visual Basic .NET. |
Keywords | PrintPreviewDialog, WindowState, dialog, dialog size, VB.NET |
Categories | Controls, VB.NET |
|
|
By default, the PrintPreviewDialog control picks its own size when it is displayed. Unfortunately that size is too small to be useful for many applications. Fortunately you can change the dialog's size and even display it maximized.
The key is to realize that the dialog is a type of form. Because the dialog is a subclass of Form, you can convert it into a Form and use Form properties to size the dialog.
The following code uses DirectCast to convert the dialog object into a Form. It sets the dialog's width and height, which are used when the dialog is in the "reatore" state. It then sets the dialog's WindowState to Maximized so the dialog initially appears maximized. Finally the code displays the dialog modally.
|
|
Private Sub btnPreview_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnPreview.Click
' Convert the dialog into a Form.
Dim dlg As Form = DirectCast(ppdTest, Form)
' Set a "restore" size.
dlg.Width = 600
dlg.Height = 400
' Start the dialog maximized.
dlg.WindowState = FormWindowState.Maximized
' Show the dialog.
ppdTest.ShowDialog()
End Sub
|
|
|
|
|
|