i've tried to print a document with many rows in my datagridview and i want to print it continously by having next page with the data not including the 1st page but it gives me the same as 1st page heres my code :
dim i as integer
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
i = i + 1
Dim bm As New Bitmap(Me.Panel2.Width, Me.Panel2.Height)
Panel2.DrawToBitmap(bm, New Rectangle(0, 0, Me.Panel2.Width, Me.Panel2.Height))
e.Graphics.DrawImage(bm, 0, 0)
If (i = 1) Then e.HasMorePages = True Else e.HasMorePages = False
Dim aPS As New PageSetupDialog
aPS.Document = PrintDocument1
End Sub
can anyone help me in this kind of problem sorry for wrong grammar thanks
What you are doing is essentially a screen print so what you see is what you get. If you want to stay with this way, you need to advance the rows on the grid so you see different records.
What you should do is look into PrintDocument for a print out that looks like a document instead of a picture.