Errr..Print The Datagrid? ( and more )

Nerine

Member
Joined
Nov 24, 2005
Messages
13
Location
Nede..Expel...???
Programming Experience
1-3
How To Print The content of The Data grid? ( In theTable Format )
i know Somewhere have the code but it hard and the code is too long to understand so i need easy and short version of the code for more easy to understand how the print work...

Other is i also want to print the data in the form that just retrieve from database and how to make it print at form format ???


p/s : pls correct me if i post on wrong section and the thing that i write too confused...:(
 
Have a look at the code for the helper class I provided the link to in post #5. The reason that printing seems somewhat complex in .NET is because it is very powerful and capable of very complex output. A more basic system would limit what you could do with it. Using GDI+ the possibilities are virtually limitless.
 
it hard to understand those helper...-.-!
is there anywhere can i find tutorial on how to print the datagrid?
if not nevermind...you all already help me so much ^^
and thank for helping me..^^
 
Hi,
I have this example, I copied from somewhere on the internet, never tried it. Maybe would help you. I am pasting it hereunder:

VB .NET example:
Private PrintGrid As DataGridPrint
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 = DataGrid1.CaptionText
.ShowDialog()
If .Result > 0 Then
PrintGrid = New DataGridPrint(PrintDocument1, DataGrid1, .bBlackWhite)
PrintGrid.PrintTitle = .bTitle
PrintGrid.Title = .Title
Select Case .Result
Case 1 ' Print
' The Print method prints the datagrid 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 DataGridPrint class starts the custom datagrid's printing process.
e.HasMorePages = PrintGrid.Print(e.Graphics)
End Sub
 
Back
Top