Print Document - e.hasmorepages
Publicado por Manuel (1 intervención) el 16/06/2011 00:23:16
Hola que tal, tengo un problema con una impresion de print Document : tengo 90 registros en la primera hoja me lista los 70 primeros hasta ai bien pero cuando hago un if y digo que si llega a 70 lineas esta pase y habilite la 2 hoja pero me sigue el for y sobrreescribe en la primera hoaj.
Private WithEvents printer As New PrintDocument
Dim tabla As New DataTable
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conex.Open()
Dim com As New SqlCommand("SS_PRINTER", conex)
com.CommandType = CommandType.StoredProcedure
Dim de As New SqlDataAdapter(com)
de.Fill(tabla)
dvgGrid.DataSource = tabla
conex.Close()
End Sub
Private Sub printer_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printer.PrintPage
'Dim lineasporpagina As Single
'Dim contado As Singleinte = 0
'Dim xpos As Single = 50
Dim prfont As New Font("Arial", 8, FontStyle.Regular)
Dim posicion As Integer = 70
' Variable para ver cuando se va hacer un salto de pagina
Dim salto_pagina As Boolean = False
Dim NroLineasPagina As Integer = 70
Dim lineaimpresa As Integer = 1
Dim pg As Integer = 1
Dim l As Integer = 1
Dim i As Integer = 1
For Each f As DataRow In tabla.Rows
'e.Graphics.DrawString(i, prfont, Brushes.Black, 50, posicion) ', New StringFormat())
e.Graphics.DrawString(f(0), prfont, Brushes.Black, 70, posicion) ', New StringFormat())
e.Graphics.DrawString(f(1), prfont, Brushes.Black, 140, posicion) ', New StringFormat())
e.Graphics.DrawString(f(2), prfont, Brushes.Black, 250, posicion)
'i += 1
posicion += 15
l += 1
lineaimpresa += 1
If l = NroLineasPagina Then
posicion = 70
l = 1
pg += 1
e.HasMorePages = True
End If
Next
e.HasMorePages = False
End Sub
gracias por su ayuda.
Private WithEvents printer As New PrintDocument
Dim tabla As New DataTable
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conex.Open()
Dim com As New SqlCommand("SS_PRINTER", conex)
com.CommandType = CommandType.StoredProcedure
Dim de As New SqlDataAdapter(com)
de.Fill(tabla)
dvgGrid.DataSource = tabla
conex.Close()
End Sub
Private Sub printer_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles printer.PrintPage
'Dim lineasporpagina As Single
'Dim contado As Singleinte = 0
'Dim xpos As Single = 50
Dim prfont As New Font("Arial", 8, FontStyle.Regular)
Dim posicion As Integer = 70
' Variable para ver cuando se va hacer un salto de pagina
Dim salto_pagina As Boolean = False
Dim NroLineasPagina As Integer = 70
Dim lineaimpresa As Integer = 1
Dim pg As Integer = 1
Dim l As Integer = 1
Dim i As Integer = 1
For Each f As DataRow In tabla.Rows
'e.Graphics.DrawString(i, prfont, Brushes.Black, 50, posicion) ', New StringFormat())
e.Graphics.DrawString(f(0), prfont, Brushes.Black, 70, posicion) ', New StringFormat())
e.Graphics.DrawString(f(1), prfont, Brushes.Black, 140, posicion) ', New StringFormat())
e.Graphics.DrawString(f(2), prfont, Brushes.Black, 250, posicion)
'i += 1
posicion += 15
l += 1
lineaimpresa += 1
If l = NroLineasPagina Then
posicion = 70
l = 1
pg += 1
e.HasMorePages = True
End If
Next
e.HasMorePages = False
End Sub
gracias por su ayuda.
Valora esta pregunta


0