Public Class groupprint

    Private Sub groupprint_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.客户TableAdapter.Fill(Me.NorthwindDataSet.客户)
        D1.DataSource = Me.NorthwindDataSet.客户
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mydgv As New VBprinter.DGVprint()
        If CheckBox1.Checked = True Then
            mydgv.GroupNewPage = True
        Else
            mydgv.GroupNewPage = False
        End If
        mydgv.GroupColumn = "联系人姓名"
        mydgv.SortColumn = "联系人姓名"
        mydgv.MainTitle = "分组打印，每组打印时在标题中显示当前组名称的打印测试"
        mydgv.SubTitle = "正在打印的组的名称是[$组名$],没错吧"
        mydgv.TableHeaderLeft = "当前组的联系人姓名：$组名$"
        mydgv.PaperLandscape = True
        mydgv.Print(D1, False)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        myp.NewDoc()
        myp.NewPage(True)
        D1.GridColor = Color.Black
        Dim ztitle As String
        Dim ztitlefont As Font = New Font("黑体", 18, FontStyle.Bold)
        Dim ftitle As String
        Dim ftitlefont As Font = New Font("宋体", 14, FontStyle.Italic)
        ztitle = "分组打印，每组打印时在标题中显示当前组名称的打印测试"
        ftitle = "正在打印的组的名称是[$组名$],没错吧"
        myp.PrintDGV(D1, ztitle, ztitlefont, ftitle, ftitlefont, StringAlignment.Center, "1111", True, True, New Font("宋体", 10), "当前组的联系人姓名：$组名$", "", "", Nothing, Nothing, Color.Black, Color.Black, "", False, False, "联系人姓名", System.ComponentModel.ListSortDirection.Ascending, "联系人姓名", CheckBox1.Checked, "", "", "", 6, True, True, True, 0, 0, Nothing, StringAlignment.Near, StringAlignment.Center, StringAlignment.Far, StringAlignment.Near, StringAlignment.Center, StringAlignment.Far, StringAlignment.Center)
        myp.EndDoc()
    End Sub

    Private Sub myp_HeaderFooterOut(ByVal pages As System.Int32, ByVal curpage As System.Int32) Handles myp.HeaderFooterOut
        myp.PrintFooter("", "第" & CStr(curpage) & "页 共" & CStr(pages) & "页", "", 6)
    End Sub
End Class