Salto de Pagina - PrintDocument
Publicado por Salto de Pagina - PrintDocument (3 intervenciones) el 16/06/2011 16:27:03
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.
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