A
Apostolos Doudakmanis
Guest
i want to print a list of names with debits, credits
the first page prints correctly but the next page prints on the first page and overflows the information
I print my own printing on a printer and in a pdf and it is my own
I'm wrong I didn't find it
Can you help me;
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim count As Integer ' Define database records
Dim pageCount As Double ' Set pages
Dim ReportFont As Font = New Font("Arial", 11)
Dim left1 As Double = SIDE_MARGIN
Dim left2 As Double
Dim top1 As Double = TOP_MARGIN
Dim VertGap As Double = VERTICAL_GAP + 5
Dim newTop As Double
Dim xPage, pPage, yPage As Double
Dim xTotal, pTotal, yTotal As Double
'--------------------------------------------------------------------------------------------------------------------------
count = DataGridView1.RowCount
pageCount = Math.Ceiling(count / LINES_PER_SHEET)
xTotal = 0
pTotal = 0
yTotal = 0
'--------------------------------------------------------------------------------------------------------------------------
If count > 0 Then
Dim dataIndex As Integer = 0
Dim i As Integer
For i = 0 To pageCount - 1 ' Number of pages to print
Dim page = i + 1
newTop = top1
'------------ Top ------------
e.Graphics.DrawString(ClubName, ReportFont, Brushes.Black, left1, newTop)
CenterPageText("Page : " & page, ReportFont, Brushes.Black, newTop, e)
RightPageText(Today, ReportFont, Brushes.Black, newTop, Convert.ToSingle(SIDE_MARGIN) * 2, e)
newTop = newTop + VertGap
e.Graphics.DrawString("Club Name", ReportFont, Brushes.Black, left1, newTop)
newTop = newTop + VertGap
e.Graphics.DrawString("", ReportFont, Brushes.Black, left1, newTop)
newTop = newTop + VertGap
If RadioButton1.Checked Then CenterPageText("Full List", ReportFont, Brushes.Black, newTop, e)
If RadioButton2.Checked Then CenterPageText("List 1", ReportFont, Brushes.Black, newTop, e)
If RadioButton3.Checked Then CenterPageText("List 2", ReportFont, Brushes.Black, newTop, e)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'newTop = newTop + VertGap
e.Graphics.DrawString("No", ReportFont, Brushes.Black, left1, newTop)
left2 = left1 + 50
e.Graphics.DrawString("Last name", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString("Name", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString("Debit", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
e.Graphics.DrawString("Credit", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
e.Graphics.DrawString("Total", ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'------------ Main Body ------------
xPage = 0
pPage = 0
yPage = 0
Dim j As Integer
For j = 0 To LINES_PER_SHEET - 1
If (dataIndex < count) Then
If j = 0 Then
Else
newTop = newTop + VertGap
End If
e.Graphics.DrawString(DataGridView1.Item(0, dataIndex).Value, ReportFont, Brushes.Black, left1, newTop)
left2 = left1 + 50
e.Graphics.DrawString(DataGridView1.Item(1, dataIndex).Value, ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString(DataGridView1.Item(2, dataIndex).Value, ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
xPage = xPage + DataGridView1.Item(3, dataIndex).Value
xTotal = xTotal + DataGridView1.Item(3, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(3, dataIndex).Value, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
pPage = pPage + DataGridView1.Item(4, dataIndex).Value
pTotal = pTotal + DataGridView1.Item(4, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(4, dataIndex).Value, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
yPage = yPage + DataGridView1.Item(5, dataIndex).Value
yTotal = yTotal + DataGridView1.Item(5, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(5, dataIndex).Value, 14), ReportFont, Brushes.Black, left2, newTop)
End If
dataIndex += 1
Next
'------------ Bottom ------------
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'newTop = newTop + VertGap
left2 = left1 + 50
e.Graphics.DrawString("Page sums: ", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 295
e.Graphics.DrawString(RSet(xPage, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 105
e.Graphics.DrawString(RSet(pPage, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 95
e.Graphics.DrawString(RSet(yPage, 14), ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
left2 = left1 + 50
e.Graphics.DrawString("General sums : ", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 295
e.Graphics.DrawString(RSet(xTotal, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 105
e.Graphics.DrawString(RSet(pTotal, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 95
e.Graphics.DrawString(RSet(yTotal, 14), ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
' ------------ Change Page -------------
'If newTop >= e.MarginBounds.Bottom Then
' e.HasMorePages = True
' End If
If dataIndex <= count Then
e.HasMorePages = True
End If
If dataIndex >= count Then
e.HasMorePages = False
'Exit Sub
End If
Next
End If
End Sub
Continue reading...
the first page prints correctly but the next page prints on the first page and overflows the information
I print my own printing on a printer and in a pdf and it is my own
I'm wrong I didn't find it
Can you help me;
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim count As Integer ' Define database records
Dim pageCount As Double ' Set pages
Dim ReportFont As Font = New Font("Arial", 11)
Dim left1 As Double = SIDE_MARGIN
Dim left2 As Double
Dim top1 As Double = TOP_MARGIN
Dim VertGap As Double = VERTICAL_GAP + 5
Dim newTop As Double
Dim xPage, pPage, yPage As Double
Dim xTotal, pTotal, yTotal As Double
'--------------------------------------------------------------------------------------------------------------------------
count = DataGridView1.RowCount
pageCount = Math.Ceiling(count / LINES_PER_SHEET)
xTotal = 0
pTotal = 0
yTotal = 0
'--------------------------------------------------------------------------------------------------------------------------
If count > 0 Then
Dim dataIndex As Integer = 0
Dim i As Integer
For i = 0 To pageCount - 1 ' Number of pages to print
Dim page = i + 1
newTop = top1
'------------ Top ------------
e.Graphics.DrawString(ClubName, ReportFont, Brushes.Black, left1, newTop)
CenterPageText("Page : " & page, ReportFont, Brushes.Black, newTop, e)
RightPageText(Today, ReportFont, Brushes.Black, newTop, Convert.ToSingle(SIDE_MARGIN) * 2, e)
newTop = newTop + VertGap
e.Graphics.DrawString("Club Name", ReportFont, Brushes.Black, left1, newTop)
newTop = newTop + VertGap
e.Graphics.DrawString("", ReportFont, Brushes.Black, left1, newTop)
newTop = newTop + VertGap
If RadioButton1.Checked Then CenterPageText("Full List", ReportFont, Brushes.Black, newTop, e)
If RadioButton2.Checked Then CenterPageText("List 1", ReportFont, Brushes.Black, newTop, e)
If RadioButton3.Checked Then CenterPageText("List 2", ReportFont, Brushes.Black, newTop, e)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'newTop = newTop + VertGap
e.Graphics.DrawString("No", ReportFont, Brushes.Black, left1, newTop)
left2 = left1 + 50
e.Graphics.DrawString("Last name", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString("Name", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString("Debit", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
e.Graphics.DrawString("Credit", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
e.Graphics.DrawString("Total", ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'------------ Main Body ------------
xPage = 0
pPage = 0
yPage = 0
Dim j As Integer
For j = 0 To LINES_PER_SHEET - 1
If (dataIndex < count) Then
If j = 0 Then
Else
newTop = newTop + VertGap
End If
e.Graphics.DrawString(DataGridView1.Item(0, dataIndex).Value, ReportFont, Brushes.Black, left1, newTop)
left2 = left1 + 50
e.Graphics.DrawString(DataGridView1.Item(1, dataIndex).Value, ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
e.Graphics.DrawString(DataGridView1.Item(2, dataIndex).Value, ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 150
xPage = xPage + DataGridView1.Item(3, dataIndex).Value
xTotal = xTotal + DataGridView1.Item(3, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(3, dataIndex).Value, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
pPage = pPage + DataGridView1.Item(4, dataIndex).Value
pTotal = pTotal + DataGridView1.Item(4, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(4, dataIndex).Value, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 100
yPage = yPage + DataGridView1.Item(5, dataIndex).Value
yTotal = yTotal + DataGridView1.Item(5, dataIndex).Value
e.Graphics.DrawString(RSet(DataGridView1.Item(5, dataIndex).Value, 14), ReportFont, Brushes.Black, left2, newTop)
End If
dataIndex += 1
Next
'------------ Bottom ------------
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
'newTop = newTop + VertGap
left2 = left1 + 50
e.Graphics.DrawString("Page sums: ", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 295
e.Graphics.DrawString(RSet(xPage, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 105
e.Graphics.DrawString(RSet(pPage, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 95
e.Graphics.DrawString(RSet(yPage, 14), ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
left2 = left1 + 50
e.Graphics.DrawString("General sums : ", ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 295
e.Graphics.DrawString(RSet(xTotal, 11), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 105
e.Graphics.DrawString(RSet(pTotal, 12), ReportFont, Brushes.Black, left2, newTop)
left2 = left2 + 95
e.Graphics.DrawString(RSet(yTotal, 14), ReportFont, Brushes.Black, left2, newTop)
newTop = newTop + VertGap
e.Graphics.DrawLine(Pens.Black, Convert.ToSingle(left1), Convert.ToSingle(newTop), Convert.ToSingle(PAPER_SIZE_WIDTH), Convert.ToSingle(newTop))
' ------------ Change Page -------------
'If newTop >= e.MarginBounds.Bottom Then
' e.HasMorePages = True
' End If
If dataIndex <= count Then
e.HasMorePages = True
End If
If dataIndex >= count Then
e.HasMorePages = False
'Exit Sub
End If
Next
End If
End Sub
Continue reading...