Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/08/2015, 18:30
CHONAIS
 
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