Public Class DrawCellTest

    Private Sub DrawCellTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        myp.InvalidatePreview()
    End Sub

    Private Sub VB2008Print1_PrintDocument() Handles myp.PrintDocument

        myp.NewPage(True) '横向演示
        myp.PageUnits = VBprinter.VB2008Print.PageExportUnit.CentiMeter '以1/100厘米为计量单位
        Dim myh As Single = 170
        Dim myw As Single = 260
        Dim myfont As New Font("宋体", 13)
        Dim myformat As StringFormat = New StringFormat(StringFormat.GenericTypographic)
        myp.DrawText("1.DrawCell函数测试（单元格边距为０，这是控件默认值，文本从左到右横向打印）", New Font("黑体", 18, FontStyle.Bold Or FontStyle.Underline))
        myp.NewRow(myp.LastDrawTextHeight)
        myp.CellMargin = New System.Drawing.Printing.Margins(0, 0, 0, 0)
        myp.DrawCell("单元格左上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格中上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)


        myp.DrawCell("单元格右上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)

        myp.NewRow(myh + 50)
        myp.DrawText("2.DrawCell函数测试（单元格边距左右上下均设置为2毫米的情况下的打印效果，文本从左到右横向打印）", New Font("黑体", 18, FontStyle.Bold Or FontStyle.Underline))
        myp.NewRow(myp.LastDrawTextHeight)
        myp.CellMargin = New System.Drawing.Printing.Margins(20, 20, 20, 20)
        myp.DrawCell("单元格左上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格中上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格右上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Near, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Center, True, False, False, False, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Far, True, False, False, False, -1, Color.Transparent, Color.Black, 0)


        myp.NewRow(myh)
        myp.NewRow(50)
        myp.DrawText("3.DrawCell函数测试（单元格边距为０，这是控件默认值，文本从上到下竖向打印）", New Font("黑体", 18, FontStyle.Bold Or FontStyle.Italic))
        myp.NewRow(myp.LastDrawTextHeight)
        myp.CellMargin = New System.Drawing.Printing.Margins(0, 0, 0, 0)
        myp.DrawCell("单元格左上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格中上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)


        myp.DrawCell("单元格右上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)

        myp.NewRow(myh + 50)
        myp.DrawText("4.DrawCell函数测试（单元格边距左右上下均设置为2毫米的情况下的打印效果，文本从上到下竖向打印）", New Font("黑体", 18, FontStyle.Bold Or FontStyle.Italic))
        myp.NewRow(myp.LastDrawTextHeight)
        myp.CellMargin = New System.Drawing.Printing.Margins(20, 20, 20, 20)
        myp.DrawCell("单元格左上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格左下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Near, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格中上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格中下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Center, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)

        myp.DrawCell("单元格右上对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Near, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右中对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Center, True, False, False, True, -1, Color.Transparent, Color.Black, 0)
        myp.DrawCell("单元格右下对齐", myw, myh, myfont, Color.Blue, "1111", StringAlignment.Far, StringAlignment.Far, True, False, False, True, -1, Color.Transparent, Color.Black, 0)

        myp.NewRow(myh + 50)
        myp.DrawText("5.DrawMulCell函数测试（这个函数在支票、进账单等类单据的小写金额套打方面很有用哦）", New Font("黑体", 18, FontStyle.Bold))
        myp.NewRow(myp.LastDrawTextHeight)
        myformat.Alignment = StringAlignment.Center
        myformat.LineAlignment = StringAlignment.Center
        myp.DrawMultiCell("亿千百十万千百十元角分", 0, True, False, myp.PaperPrintWidth / 2, myp.MeasureCell("测试", myfont).Height, myfont, Color.Red, myformat, "1111", Color.Blue, 0, 0)
        myp.NewRow(myp.LastDrawTextHeight)
        If myp.IsNewPage(myp.MeasureCell("测试", myfont).Height) Then
            myp.NewPage(True)
        End If
        myp.DrawMultiCell("253658278", 11, True, False, myp.PaperPrintWidth / 2, myp.MeasureCell("测试", myfont).Height, myfont, Color.Red, myformat, "1111", Color.Blue, 0, 0)
       
    End Sub
End Class