代码之家  ›  专栏  ›  技术社区  ›  Karl

如何引发PrintPage的事件?

  •  0
  • Karl  · 技术社区  · 2 年前

    当im在表格1中时,如何引发表格2中打印页面的事件

      Public Sub PrintDocument1_PrintPage_1(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Dim dm As New Bitmap(Me.Panel1.Width, Me.Panel1.Height)
            Panel1.DrawToBitmap(dm, New Rectangle(0, 0, Me.Panel1.Width, Me.Panel1.Height))
            e.Graphics.DrawImage(dm, 0, 0)
    
            Dim aPS As New PageSetupDialog
            aPS.Document = PrintDocument1
    
        End Sub
    

    我希望能够在这里提出这一事件

    Public Sub printall()
            If txtempname.Items.Count = 0 Then
                MessageBox.Show("There is no Record to Print")
            Else
                For i = 0 To txtempname.Items.Count - 1
                    txtempname.SelectedIndex = i
                    getEmployeeInfo()
                    getattendance()
                    getDeductions()
                    getExtraDeductions()
                    getLoans()
                    calculate()
                    printallnote()
                    PrintPayslip.payslip()
    
                    'Raised PrintPage event here
    
                    PrintPayslip.print()
                    PrintPayslip.Close()
                Next
            End If
        End Sub
    
    1 回复  |  直到 2 年前
        1
  •  1
  •   John    2 年前

    你打电话 Print 在您的 PrintDocument BeginPrint 首先是事件,然后是 PrintPage e.HasMorePages True 打印页面 活动将继续进行。最后 EndPrint 将引发事件。

    ShowDialog PrintPreviewDialog ,当用户单击