Click here to Skip to main content
15,914,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how Print preview and print Datagridview with add title and sub title in vb.net
Posted

You would have probably got a faster response typing your question into Google and working your way through the 400k+ results!

Have a look at this CodeProject article Another DataGridView Printer[^] - it's in c# but there are free converters on the web.

Here's another one in VB this time http://www.xmlfox.com/print_datagridview.htm[^]
 
Share this answer
 
Comments
Hemant L Patil 17-Jul-14 9:14am    
Type DGVPrinter is not define error disply i have add DGVPrinter.dll file and DGVPrinter.cs
but error display import and imports DGVPrinterHelpe also error
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click

With Printer
Printer.Title = "Your Title"
Printer.SubTitle = "Your Subtitle"
Printer.SubTitleFormatFlags = StringFormatFlags.LineLimit Or _
StringFormatFlags.NoClip
Printer.PageNumbers = True
Printer.PageNumberInHeader = False
Printer.PorportionalColumns = True
Printer.HeaderCellAlignment = StringAlignment.Near
Printer.Footer = "Your Footer"
Printer.FooterSpacing = 15
Printer.PrintDataGridView(Me.DataGridView1)
End With

End Sub

Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
With Me.PrintPreviewDialog1
.Document = Printer.printDocument
If .ShowDialog = DialogResult.OK Then

Printer.PrintDataGridView(Me.DataGridView1)
End If

End With

End Sub
 
Share this answer
 
Comments
Hemant L Patil 18-Jul-14 2:12am    
not working fail to add printer
nilesh sawardekar 18-Jul-14 2:20am    
how your doing that let me check..
Hemant L Patil 18-Jul-14 4:22am    
DGVPrinter.vb file has error display
nilesh sawardekar 18-Jul-14 5:01am    
Looks like you didnt reply what i had suggest to you.
Dinesh Babu 2023 29-Jun-23 9:21am    
how to box create in dgvprinter

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900