Print Datagridview

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • OuTCasT
    Contributor
    • Jan 2008
    • 374

    Print Datagridview

    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]
    Last edited by Shashi Sadasivan; Jan 29 '08, 10:06 AM. Reason: changing code tag from vb to vbnet
  • radcaesar
    Recognized Expert Contributor
    • Sep 2006
    • 759

    #2
    Reply with the exact error no and message

    Comment

    Working...