Printing from Managed code is accomplished using the
PrintDocument control from the Visual Studio.NET ToolBox. Add the control to
your application, then use it as illustrated below; in this example only the
barcode is printed.
Private Sub print1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles print1.Click
Try
AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintDocument1_PrintPage
PrintDocument1.Print()
Catch ex As Exception
MessageBox.Show("An error occurred while printing", _
ex.ToString())
End Try
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.PageUnit = GraphicsUnit.Document '
e.Graphics.DrawString(Dfont1.Barcode, Dfont1.Font, Brushes.Black, 300.0F, 300.0F)
' Indicate that this is the last page to print.
e.HasMorePages = False
End Sub
More: