Visual Basic - impresion de datagridview

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

impresion de datagridview

Publicado por pabnoc (2 intervenciones) el 12/01/2017 11:20:55
Buenos dias.... mi consulta esl a siguiente, estoy realizando una impresion de un datagridview...

Visualbasic express 2012...

pero al imprimir me manda como 200 paginas de la pag 1 nada mas... en que estoy fallando...?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Private Sub LISTABindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles LISTABindingNavigatorSaveItem.Click
        Me.Validate()
        Me.LISTABindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.STOCKDataSet)
 
    End Sub
 
    Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
        Me.LISTATableAdapter.Fill(Me.STOCKDataSet.LISTA)
 
    End Sub
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        PrintDocument1.Print()
    End Sub
 
    Private Sub PrintDocument1_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
 
        Dim i As Integer = 0
 
        Dim printFont As System.Drawing.Font = New Font("Arial", 10)
        Dim topMargin As Double = e.MarginBounds.Top
        Dim yPos As Double = 0
        Dim linesPerPage As Double = 0
        Dim count As Integer = 0
        Dim texto As String = ""
        Dim row As System.Windows.Forms.DataGridViewRow
 
 
        linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)
 
 
        Dim header As DataGridViewHeaderCell
        For Each column As DataGridViewColumn In LISTADataGridView.Columns
            header = column.HeaderCell
            texto += vbTab + header.FormattedValue.ToString()
        Next
 
        yPos = topMargin + (count * printFont.GetHeight(e.Graphics))
        e.Graphics.DrawString(texto, printFont, System.Drawing.Brushes.Black, 10, yPos)
 
        count += 2
 
 
        While count < linesPerPage AndAlso i < LISTADataGridView.Rows.Count
            row = LISTADataGridView.Rows(i)
            texto = ""
            For Each celda As System.Windows.Forms.DataGridViewCell In row.Cells
 
                If celda.Value IsNot Nothing Then
                    texto += vbTab + celda.Value.ToString()
                End If
            Next
 
            yPos = topMargin + (count * printFont.GetHeight(e.Graphics))
 
 
            e.Graphics.DrawString(texto, printFont, System.Drawing.Brushes.Black, 10, yPos)
 
 
            count += 1
            i += 1
        End While
 
 
        If i < LISTADataGridView.Rows.Count Then
            e.HasMorePages = True
        Else
 
            e.HasMorePages = False
 
            i = 0
        End If
    End Sub
 
 
 
 
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Me.Close()
    End Sub
 
 
End Class

987777
987778
987782

me darian una mano si no es molestia gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder