Share via


PrintForm.PrintAction Property

Gets or sets a value indicating whether the output is directed to a printer, to a print preview window, or to a file.

Namespace:  Microsoft.VisualBasic.PowerPacks.Printing
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Property PrintAction As PrintAction
[BrowsableAttribute(true)]
public PrintAction PrintAction { get; set; }
[BrowsableAttribute(true)]
public:
property PrintAction PrintAction {
    PrintAction get ();
    void set (PrintAction value);
}
[<BrowsableAttribute(true)>]
member PrintAction : PrintAction with get, set
function get PrintAction () : PrintAction 
function set PrintAction (value : PrintAction)

Property Value

Type: PrintAction
Returns a PrintAction enumeration.

Remarks

When PrintToPrinter is selected, the output is directed to the system default printer. You can override this behavior and explicitly set the printer and printer properties by using the PrinterSettings property. If no default printer is available, the user is prompted to select a printer.

When PrintToPreview is selected, the form is displayed in a standard Windows Forms PrintPreviewDialog control.

When PrintToFile is selected, an image of the form is saved to an Encapsulated PostScript file (.eps, .ps, or .ai) in the path specified by the PrintFileName property. If no file name is specified, the user is prompted for a file name.

Note

Files are saved in an 8-bit Greyscale PostScript format. 24-bit RGB PostScript is not supported.

Note

The user is not prompted for a path or file name extension. To make sure that the file has a valid path and extension, you can implement your own dialog box. To do this, use a SaveFileDialog component and assign the return value to the PrintFileName property before calling the Print method.

Examples

The following example demonstrates how to set the PrintAction property. This example requires that you have a PrintForm component named PrintForm1 and three RadioButton controls on a form.

If RadioButton1.Checked = True Then
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPrinter
ElseIf RadioButton2.Checked = True Then
    PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
Else
    PrintForm1.PrintFileName = _
  My.Computer.FileSystem.SpecialDirectories.CurrentUserApplicationData _
  & "Form1.eps"
    PrintForm1.PrintAction = Printing.PrintAction.PrintToFile
End If

.NET Framework Security

See Also

Reference

PrintForm Class

Microsoft.VisualBasic.PowerPacks.Printing Namespace

Other Resources

PrintForm Component (Visual Basic)

How to: Print a Form by Using the PrintForm Component (Visual Basic)

How to: Print the Client Area of a Form (Visual Basic)

How to: Print Client and Non-Client Areas of a Form (Visual Basic)

How to: Print a Scrollable Form (Visual Basic)

Deploying Applications That Reference the PrintForm Component (Visual Basic)