dopo aver passato i dati di un datagrid su una tabella e richiamato la funzione Buttonstampa la form ne avvia la stampa avviando la sub pDoc_PrintPage
il tutto funziona ma ........ in un pagina posso stampare 38 records e non so come dire al programma arrivato a 38 con indr (che indica la riga presa in stampa)avvia una seconda pagina
Private Sub pDoc_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pDoc.PrintPage
Dim b As String
Dim sp As Integer
Dim myfont As New Font("Verdana", 10, FontStyle.Regular, GraphicsUnit.Pixel)
Dim myfont2 As New Font("Verdana", 7, FontStyle.Regular, GraphicsUnit.Pixel)
Dim ColWidth As Integer = 0
Dim righe As Integer
Dim spazio As Integer
Dim indr As Integer
Dim colonne As Integer
Dim indc As Integer
Select Case (cosa)
Case "stampanti"
righe = tblClienti.Rows.Count
spazio = 20
indc = 0
colonne = tblClienti.Columns.Count
While indc < colonne - 1
e.Graphics.DrawString(tblClienti.Columns(indc).Col umnName, myfont, New SolidBrush(Color.Black), 15 + (indc * 133), 100)
indc = indc + 1
End While
indc = 0
indr = 0
While indr < righe
While indc < colonne - 1
Try
b = CStr(tblClienti.Rows(indr).Item(indc))
If b = "True" Then
b = "|X|"
End If
If b = "False" Then
b = "| |"
End If
Catch
b = ""
End Try
e.Graphics.DrawString(b, myfont, New SolidBrush(Color.Black), 15 + (indc * 133), 100 + spazio + sp)
' sp = sp + 10
indc = indc + 1
End While
indc = 0
spazio = spazio + 11 + sp
e.Graphics.DrawString("___________________________ __________________________________________________ _______________", myfont, New SolidBrush(Color.Black), 15, 100 + spazio)
If indr = 38 Then
'avvia una nuova pagina
End If
indr = indr + 1
spazio = spazio + 15
End While
End Select
End Sub
Private Sub Buttonstampa(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim PrintDialog1 As New PrintDialog
pDoc = New Printing.PrintDocument
PrintDialog1.Document = pDoc
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog() = DialogResult.OK Then
pDoc.Print()
End If
End Sub