ขอความอนุเคราะห์ช่วยตรวจสอบแก้ไข Code ในการ print ข้อมูล ภายใน DataGridView ของโปรแกรม Visual Studio 2013 C#

private void printDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            e.Graphics.DrawString("Header Report Title", new Font("Arial", 20), Brushes.Black, 10, 10);
            e.Graphics.DrawLine(Pens.Gray, 10, 50, 830, 50);


            int position = 130;
            e.Graphics.DrawString("-- Data from Data Grid View --", new Font("Arial", 16), Brushes.Black, 10, 100);
            foreach (DataGridViewRow  item in dataGridView1.Rows)
            {
               e.Graphics.DrawString((string)item.Cells[1].Value, new Font("Arial", 10), Brushes.Black, 10, position);
               position += 20;
               e.Graphics.DrawString((string)item.Cells[2].Value, new Font("Arial", 10), Brushes.Black, 10, position);
               position += 20;

            }


            e.Graphics.DrawLine(Pens.Gray, 10, 1050, 830, 1050);
            e.Graphics.DrawString("Footer Report Title", new Font("Arial0", 20), Brushes.Black, 10, 1060);

อันเก่าเป็น สั่งพิมพ์แบบ Row
ผมจะเปลี่ยนเป็น Column
จะมีปัญหาที่ โค็ด

foreach (DataGridViewRow  item in dataGridView1.Rows)
            {
               e.Graphics.DrawString((string)item.Cells[1].Value, new Font("Arial", 10), Brushes.Black, 10, position);
               position += 20;
               e.Graphics.DrawString((string)item.Cells[2].Value, new Font("Arial", 10), Brushes.Black, 10, position);
               position += 20;

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