jeudi 27 décembre 2007

Printing a Form with Power Pack for Visual Basic 2005

Sometimes, we need to print a VB Form especially if it contains charts or data tables. A simple solution for printing forms in VB .Net 2005 is to use the Power Pack.

The Power Pack is a free toolkit for VB .Net 2005 which allows the developer to draw a line and an oval/rectangle shape. It also used to print a form. To download the Power Pack, go to: http://msdn2.microsoft.com/fr-fr/vbasic/bb735936.aspx

Using the Print Form is very easy.

Sample Code:
' Set the PrintAction to display a Print Preview dialog
PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
' Print a copy of the form
PrintForm1.Print(Me, PowerPacks.Printing.PrintForm.PrintOption.FullWindow)

You can also hide the parts of the forms that you don't want to print. The Power Pack contains an example of how to use the Print Form.

Aucun commentaire: