Foros del Web » Programación para mayores de 30 ;) » .NET »

Como agregar mas paginas e.HasMorePages????

Estas en el tema de Como agregar mas paginas e.HasMorePages???? en el foro de .NET en Foros del Web. Hola soy nuevo en esto de .NET y me he atorado a la hora de querer imprimir con un PrintDocument, quiero imprimir muchas lineas con ...
  #1 (permalink)  
Antiguo 18/08/2015, 18:30
 
Fecha de Ingreso: agosto-2015
Mensajes: 1
Antigüedad: 8 años, 8 meses
Puntos: 0
Pregunta Como agregar mas paginas e.HasMorePages????

Hola soy nuevo en esto de .NET y me he atorado a la hora de querer imprimir con un PrintDocument, quiero imprimir muchas lineas con registros que estoy tomando de un DataGridView pero solo imprime una Hoja y no se en donde agregar el código para meter el e.HasMorePages. Ayuda por favor

Este es mi código:

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
DatGv = Reportes.DataGridView_Registros
Dim SaltoLn As Integer = 180
Dim j As Integer = 1
Dim fechaimp As String
fechaimp = Date.Now
nRows = DatGv.RowCount - 1
e.Graphics.DrawString("Fecha impresión " & fechaimp, SystemFonts.DefaultFont, Brushes.Black, 550, 60)
e.Graphics.DrawString("REPORTE DE ENTRADAS Y SALIDAS DE PERSONAL GRUPO BACIS", TituloFont, System.Drawing.Brushes.Black, 50, 80)
e.Graphics.DrawString("Ciudad Industrial", TituloFont, System.Drawing.Brushes.Black, 360, 105)
e.Graphics.DrawString("Nombre", printFont, System.Drawing.Brushes.Black, 100, 150)
e.Graphics.DrawString("Apellidos", printFont, System.Drawing.Brushes.Black, 200, 150)
e.Graphics.DrawString("Depto", printFont, System.Drawing.Brushes.Black, 400, 150)
e.Graphics.DrawString("Hora", printFont, System.Drawing.Brushes.Black, 500, 150)
e.Graphics.DrawString("Registro", printFont, System.Drawing.Brushes.Black, 600, 150)
e.Graphics.DrawString("Fecha", printFont, System.Drawing.Brushes.Black, 700, 150)
e.Graphics.DrawString("___________________________ _________________________________", TituloFont, System.Drawing.Brushes.Black, 50, 153)

While nRows > 0
Dim cel1 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.Nombre.H eaderText, cel1).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 100, SaltoLn)
Dim cel2 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.Apellido s.HeaderText, cel2).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 200, SaltoLn)
Dim cel3 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.Depto..H eaderText, cel3).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 400, SaltoLn)
Dim cel4 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.EntradaS alida.HeaderText, cel4).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 500, SaltoLn)
Dim cel5 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.Hora.Hea derText, cel5).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 600, SaltoLn)
Dim cel6 = DatGv.CurrentCell.RowIndex + j - 1
e.Graphics.DrawString(DatGv.Item(Reportes.Fecha.He aderText, cel6).Value.ToString, SystemFonts.DefaultFont, Brushes.Black, 700, SaltoLn)
j = j + 1
SaltoLn = SaltoLn + 20
nRows = nRows - 1
End While

End Sub

Private Sub btn_Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Print.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print()
End If
End Sub

End Class
  #2 (permalink)  
Antiguo 24/08/2015, 07:14
 
Fecha de Ingreso: noviembre-2012
Mensajes: 43
Antigüedad: 11 años, 5 meses
Puntos: 0
Respuesta: Como agregar mas paginas e.HasMorePages????

Buen dia, para tener el hasmore pages tenes que tener una variable global, y sobre eso controlar cuando tenes que hacer el salto de linea en el procedimiento en donde imprime, porque eso lo que hace es primero ejecutar y despues imprimir, o sea, ejecuta todo el codigo y cuando termina de armar el documento, imprime. Tenes que tener en cuenta que vas a controlar, si es una cantidad X de items por pagina tenes que ir controlando eso y poner el contador en 0.
Ejemplo:

Variable global

Dim CantidadItems As Integer = 0
Dim Indice As Integer

proceso imprimir ---
Dim Contador As Integer = 0
-
Codigo de texto a imprimir
-
CantidadItems = CantidadItems - 1
Contador = Contador + 1
Indice = Indice + 1
If Contador = 3 Then
If CantidadItems = 0 Then
e.HasMorePages = False
Else
e.HasMorePages = True
End If
Exit Sub
Else
If CantidadItems = 0 Then
e.HasMorePages = False
End If

End If


Espero que te sirva, sino, me contas!!! Saludos

Pablo Germán Giribaldi - Analista de sistemas

Etiquetas: net
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:49.