Хотел напечатать отчет, способный напечатать одну страницу, то есть до 45 строк, а остальные строки не печатаются, не в состоянии создать дальнейшие новые страницы.
I am using VB.net 2010 and MS Access and I need to print a report, I am able to print a single page i.e upto 45 lines and the remaining lines are not printing, unable to create further new pages. Please help, thanks in advance This is my code: Public Class frmReport Dim conn As New OleDb.OleDbConnection Dim strMonthNo As String Dim y As Integer Private Sub LoadStocksOutReport() Dim totTransactions As Integer Dim totSales As Double Dim totCreditSales As Double Dim totPayments As Double Dim sqL As String Dim GridRow As DataGridViewRow Try If Not conn.State = ConnectionState.Open Then 'open connection conn.Open() End If If frmFilterMonthlyReport.chkMonthly.Checked = True Then sqL = "SELECT [invoiceNo], [tDate], [customer_Name], [job], [cashOrCredit], [totalAmount] FROM transactions WHERE tDate LIKE '" & strMonthNo & "%' AND tDate LIKE '%" "' ORDER BY invoiceNo" Else sqL = "SELECT [invoiceNo], [tDate], [customer_Name], [job], [cashOrCredit], [totalAmount] FROM transactions WHERE tDate LIKE '%" "' ORDER BY invoiceNo" End If Dim cmd = New OleDb.OleDbCommand(sqL, conn) Dim dr As OleDb.OleDbDataReader dr = cmd.ExecuteReader() dgw.Rows.Clear() totTransactions = 0 totSales = 0.0 totCreditSales = 0.0 totPayments = 0.0 y = 0 Do While dr.Read = True dgw.Rows.Add(dr("invoiceNo"), Format(dr("tDate"), "dd/MM/yyyy"), dr("customer_Name"), dr("job"), dr("cashOrCredit"), Format(dr("totalAmount"), "#,##0.00")) y += 19 totTransactions += 1 totSales += dr("totalAmount") If dr("cashOrCredit").ToString = "Credit" Then totCreditSales += dr("totalAmount") Else totPayments += dr("totalAmount") End If Loop dgw.Height += y lblTotalStocksIn.Text = totTransactions lblTotalSales.Text = Format(totSales, "#,##0.00") lblTotalCredits.Text = Format(totCreditSales, "#,##0.00") lblTotalCashPayments.Text = Format(totPayments, "#,##0.00") Panel3.Location = New Point(Me.Panel3.Location.X, Me.Panel3.Location.Y + y) Catch ex As Exception MsgBox(ex.ToString) Finally conn.Close() conn.Dispose() End Try End Sub Private Sub frmMonthlyReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load conn = New OleDb.OleDbConnection conn.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" & Application.StartupPath & "\testDB.mdb" If frmFilterMonthlyReport.chkMonthly.Checked = True Then lblCollections.Text = "Sales for the Month of " & frmFilterMonthlyReport.cmbMonth.Text & " " & frmFilterMonthlyReport.cmbYear.Text Else frmFilterMonthlyReport.chkYearly.Checked = True lblTitle.Text = "Yearly Sales Report" lblCollections.Text = "Sales for the Year of " & frmFilterMonthlyReport.cmbYear.Text End If LoadStocksOutReport() lbldate.Text = Date.Now.ToString("dd-MM-yyyy") End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim bm As New Bitmap(Me.Panel1.Width, Me.Panel1.Height) Panel1.DrawToBitmap(bm, New Rectangle(0, 0, Me.Panel1.Width, Me.Panel1.Height)) e.Graphics.DrawImage(bm, 0, 40) Dim aPS As New PageSetupDialog aPS.Document = PrintDocument1 End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintDialog1.Document = Me.PrintDocument1 Dim ButtonPressed As DialogResult = PrintDialog1.ShowDialog() If (ButtonPressed = DialogResult.OK) Then Panel1.Height += y PrintDocument1.Print() Me.Close() End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Close() End Sub End Class
Что я уже пробовал:
Приведенный выше код отлично работает для печати одной страницы, то есть до 45 строк, а дальнейшие строки не могут быть напечатаны, и никакие новые страницы не создаются для печати оставшихся строк.