Sunteți pe pagina 1din 4

Private Sub buttonPrint_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim printDialog1 As PrintDialog = New PrintDialog printDialog1.

Document = printDocument1 Dim result As DialogResult = printDialog1.ShowDialog If (result = DialogResult.OK) Then printDocument1.Print() End If End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.Scrollable) End Sub

NEXT PAGES HTML:

http://msdn.microsoft.com/en-us/library/bb629268.aspx

How to: Print a Form by Using the PrintForm Component (Visual Basic)
Visual Studio 2010 Other Versions

The PrintForm component enables you to quickly print an image of a form exactly as it appears on screen without using a PrintDocument component. The following procedures show how to print a form to a printer, to a print preview window, and to an Encapsulated PostScript file.

To print a form to the default printer


1. In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form. The PrintForm component is added to the component tray. 2. In the Properties window, set the PrintAction property to PrintToPrinter. 3. Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
4. PrintForm1.Print()

To display a form in a print preview window

1. In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form. The PrintForm component is added to the component tray. 2. In the Properties window, set the PrintAction property to PrintToPreview. 3. Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
4. PrintForm1.Print()

To print a form to a file


1. In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form. The PrintForm component is added to the component tray. 2. In the Properties window, set the PrintAction property to PrintToFile. 3. Optionally, select the PrintFileName property and type the full path and file name for the destination file. If you skip this step, the user will be prompted for a file name at run time. 4. Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
5. PrintForm1.Print()

See Also

Tasks 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) Reference PrintAction PrintFileName Concepts PrintForm Component (Visual Basic) Community Content Add FAQ Advertisement

2011 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Feedback

S-ar putea să vă placă și