.VB คำสั่ง e.Graphics ใช้ยังไงครับ

คือใช้โค๊ดนี้ในการพิมพ์ข้อมูลจาก access


Dim ColumnCount As Integer = DataGridView1.ColumnCount
        Dim RowCount As Integer = DataGridView1.RowCount

        Dim CellTopPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Top

        For Row = 0 To RowCount - 2

            Dim CellLeftPos As Integer = PrintDocument1.PrinterSettings.DefaultPageSettings.Margins.Left

            For Cell = 0 To ColumnCount - 1

                Dim CellValue As String = DataGridView1.Rows(Row).Cells(Cell).Value.ToString()
                Dim CellWidth = DataGridView1.Rows(Row).Cells(Cell).Size.Width + 10
                Dim CellHeight = DataGridView1.Rows(Row).Cells(Cell).Size.Height

                Dim Brush As New SolidBrush(Color.Black)
                e.Graphics.DrawString(CellValue, New Font("arial", 9), Brush, CellLeftPos, CellTopPos)
                e.Graphics.DrawRectangle(Pens.Black, CellLeftPos, CellTopPos, CellWidth, CellHeight)

                CellLeftPos += CellWidth
            Next

            CellTopPos += DataGridView1.Rows(Row).Cells(0).Size.Height
        Next

คือใช้คำสั่งนี้ มัน error ตรง e.Graphics.DrawString(CellValue, New Font("arial", 9), Brush, CellLeftPos, CellTopPos)
                e.Graphics.DrawRectangle(Pens.Black, CellLeftPos, CellTopPos, CellWidth, CellHeight)

    แก้ยังไงอ่า
หรือว่าใครมีโค๊ดปริ้นข้อมูลจาก databest access ก็ได้ครับ
ช่วยหน่อยคับ T_T
แก้ไขข้อความเมื่อ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่