Lid |
|
Wss voor VB.NET 2005 en ik werk met 2008
Private PrintGrid As DataGridViewPrint
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
Dim fpr As New frmPrint()
With fpr
.Title = DataGridView1.CaptionText
.ShowDialog()
If .Result > 0 Then
PrintGrid = New DataGridViewPrint(PrintDocument1, DataGridView1, .bBlackWhite)
PrintGrid.PrintTitle = .bTitle
PrintGrid.Title = .Title
Select Case .Result
Case 1 ' Print
' The Print method prints the DataGridView without using a print dialog.
' Use a PrintDialog when you want to offer the user the ability to choose print settings.
If PrintDialog1.ShowDialog() = DialogResult.OK Then PrintDocument1.Print()
Case 2 ' Page Setup
PageSetupDialog1.ShowDialog()
Case 3 ' Preview
PrintPreviewDialog1.Icon = fpr.Icon
PrintPreviewDialog1.ShowDialog()
End Select
End If
End With
End Sub
' Specify the output to print by handling the PrintPage event
' and by using the Graphics included in the PrintPageEventArgs.
Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Print method of DataGridViewPrint class starts the custom DataGridView's printing process.
e.HasMorePages = PrintGrid.Print(e.Graphics)
End Sub
Private PrintGrid As DataGridViewPrint Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click Dim fpr As New frmPrint() With fpr .Title = DataGridView1.CaptionText .ShowDialog() If .Result > 0 Then PrintGrid = New DataGridViewPrint(PrintDocument1, DataGridView1, .bBlackWhite) PrintGrid.PrintTitle = .bTitle PrintGrid.Title = .Title Select Case .Result Case 1 ' Print ' The Print method prints the DataGridView without using a print dialog. ' Use a PrintDialog when you want to offer the user the ability to choose print settings. If PrintDialog1.ShowDialog() = DialogResult.OK Then PrintDocument1.Print() Case 2 ' Page Setup PageSetupDialog1.ShowDialog() Case 3 ' Preview PrintPreviewDialog1.Icon = fpr.Icon PrintPreviewDialog1.ShowDialog() End Select End If End With End Sub ' Specify the output to print by handling the PrintPage event ' and by using the Graphics included in the PrintPageEventArgs. Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage ' Print method of DataGridViewPrint class starts the custom DataGridView's printing process. e.HasMorePages = PrintGrid.Print(e.Graphics) End Sub
|