อยากจะเขียนรายงาน ด้วยภาษา c# ให้มีหน้ามากกว่า 1 หน้า โดยไม่ใช้ crystal report (รบกวนผู้รู้ช่วยหน่อยครับ)

โค้ดที่ผมเขียน กดแสดงตัวอย่างก่อนพิมพ์ มันนับเลขหน้าไม่หยุด
StringBuilder newlineTesting = new StringBuilder();


            int position = 110;
            int line = 75;

            e.Graphics.DrawString(" รายงาน วัสดุ อุปกรณ์ / เครื่องมือช่าง คงเหลือ ", new Font("Angsana New", 15), Brushes.Black, 290, 10);
            e.Graphics.DrawString("วันที่   " + label17.Text.ToString() + "    เวลา  "  + label18.Text.ToString() + "", new Font("Angsana New", 15), Brushes.Black, 320, 35);
            e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------", new Font("Angsana New", 15), Brushes.Black, 50, 50);
            e.Graphics.DrawString("ประเภท    " + "  " + "    รหัส    " + " " + "             ชื่ออุปกรณ์                  " + "    " + "      ขนาด     " + "      " + "           รายละเอียด                 " + "     " + "        เหลือ    " + "   " + "      หน่วย     " , new Font("Angsana New", 15), Brushes.Black, 50, 70);
            e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------", new Font("Angsana New", 15), Brushes.Black, 50, 85);
            foreach (DataGridViewRow item in dataGridView4.Rows)
            {


                e.Graphics.DrawString((string)item.Cells[0].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 55, position);
                e.Graphics.DrawString((string)item.Cells[1].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 130, position);
                e.Graphics.DrawString((string)item.Cells[2].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 180, position);
                e.Graphics.DrawString((string)item.Cells[3].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 380, position);
                e.Graphics.DrawString((string)item.Cells[4].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 450, position);
                e.Graphics.DrawString((string)item.Cells[5].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 660, position);
                e.Graphics.DrawString((string)item.Cells[6].Value.ToString(), new Font("Angsana New", 13), Brushes.Black, 740, position);

                position += 26;
                line += 22;


/*

                if (position >= e.MarginBounds.Bottom)
                    {

                        e.HasMorePages = true;
                        return;
                    }
                    else
                    {
                        e.HasMorePages = false;

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