Public Class SimpleReportTest4

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mysp As New VBprinter.SimpleReport()
        Dim mymbfile As String
        mymbfile = My.Application.Info.DirectoryPath & "\" & "第六个打印方案.yp"
        mysp.SetReportDataSource(d1)
        mysp.IsImmediatePrint = False
        mysp.Print(mymbfile, True, True, True)
    End Sub

  

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        '将SimpleReport组件创建的报表打印预览内容在指定的VB2008Print组件中打印预览
        Dim mysp As New VBprinter.SimpleReport()
        Dim mymbfile As String
        mymbfile = My.Application.Info.DirectoryPath & "\" & "第六个打印方案.yp"
        mysp.SetReportDataSource(d1)
        p.NewDoc()
        p.PrintSimpleReport(mymbfile, mysp)
        p.EndDoc()
       

    End Sub

    Private Sub SimpleReportTest4_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'TODO: 这行代码将数据加载到表“NorthwindDataSet.产品”中。您可以根据需要移动或移除它。
        Me.产品TableAdapter.Fill(Me.NorthwindDataSet.产品)
    End Sub

    Private Sub p_HeaderFooterOut(ByVal pages As System.Int32, ByVal curpage As System.Int32) Handles p.HeaderFooterOut
        p.PrintFooter("中南林", "第" & CStr(curpage) & "页 共" & CStr(pages) & "页", "", 0)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        p.NewDoc()
        p.NewPage()
        p.DrawText("先直接用VB2008Print组件的PrintDGV方法打印DataGridView的内容，然后再把SimpleReport组件打印内容添加到此表中，在此种打印方式下，您最好不要在SimpleReport报表的页眉与页脚使用使用页码与总页数，而应像本演示一样处理，这样在页眉与页脚中显示的页码与总页数才是正确的。", New Font("黑体", 12), Color.Blue)
        p.NewRow(p.LastDrawTextHeight)
        p.PrintDGV(d1, "直接用VB2008Print组件打印DataGridView", New Font("黑体", 20, FontStyle.Bold), StringAlignment.Center)
        p.DrawText("PrintDGV方法打印完毕，从下一页开始显示SimpleReport组件默认打印方案的内容")
        Dim mysp As New VBprinter.SimpleReport()
        Dim mymbfile As String
        mymbfile = My.Application.Info.DirectoryPath & "\" & "第六个打印方案.yp"
        mysp.SetReportDataSource(d1)
        p.PrintSimpleReport(mymbfile, mysp)
        p.NewPage()
        p.DrawText("打印完SimpleReport方法后，您需要调用NewPage函数创建新页，再在新页中打印其他内容。请注意看，SimpleReport组件中打印的报表内容的纸张与页边距都是独立的。")
        p.EndDoc()
    End Sub
End Class