Can some one please tell me if this is the correct way to print data from a gridview because it gives me an error
[CODE=vbnet]Private PrintGrid As DataGridViewPri nt
Private Sub btnPrint_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnPrint.Click
Dim fpr As New frmPrint()
With fpr
.Title = DataGridView1.C aptionText
.ShowDialog()
If .Result > 0 Then
PrintGrid = New DataGridViewPri nt(PrintDocumen t1, DataGridView1, .bBlackWhite)
PrintGrid.Print Title = .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.Sh owDialog() = DialogResult.OK Then PrintDocument1. Print()
Case 2 ' Page Setup
PageSetupDialog 1.ShowDialog()
Case 3 ' Preview
PrintPreviewDia log1.Icon = fpr.Icon
PrintPreviewDia log1.ShowDialog ()
End Select
End If
End With
End Sub[/CODE]
[CODE=vbnet]Private PrintGrid As DataGridViewPri nt
Private Sub btnPrint_Click( ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnPrint.Click
Dim fpr As New frmPrint()
With fpr
.Title = DataGridView1.C aptionText
.ShowDialog()
If .Result > 0 Then
PrintGrid = New DataGridViewPri nt(PrintDocumen t1, DataGridView1, .bBlackWhite)
PrintGrid.Print Title = .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.Sh owDialog() = DialogResult.OK Then PrintDocument1. Print()
Case 2 ' Page Setup
PageSetupDialog 1.ShowDialog()
Case 3 ' Preview
PrintPreviewDia log1.Icon = fpr.Icon
PrintPreviewDia log1.ShowDialog ()
End Select
End If
End With
End Sub[/CODE]
Comment