当我从Datagridview打印这个时,值是一个在另一个上面的,在这里输入图像描述
Dim rowCount As Integer = DataGridView6.Rows.Count
For i = 0 To rowCount - 1
e.Graphics.DrawString("PARTICULARS", ReportBodyFont, Brushes.Black, 70, 300)
e.Graphics.DrawString("QTY", ReportBodyFont, Brushes.Black, 400, 300)
e.Graphics.DrawString("AMOUNT", ReportBodyFont, Brushes.Black, 600, 300)
e.Graphics.DrawString("----------------------------------------------------------", ReportFont, Brushes.Black, 50, 310)
''
e.Graphics.DrawString(DataGridView6.Rows(i).Cells(1).Value, ReportBodyFont, Brushes.Black, 50, 320)
e.Graphics.DrawString(DataGridView6.Rows(i).Cells(3).Value, ReportBodyFont, Brushes.Blue, 400, 320)
e.Graphics.DrawString(DataGridView6.Rows(i).Cells(2).Value, ReportBodyFont, Brushes.Black, 600, 320)
Next
当然是。每一行都使用完全相同的坐标。如果您希望每一行都打印在前一行的下方,则需要指定一个大于上一行的Y。一般来说,您会为第一条记录和记录的高度建立一个基线,然后为每一行使用一个Y坐标,即该基线加上行索引乘以高度,例如
Dim y0 = 10
Dim rowHeight = 50
For rowIndex = 0 To rowCount - 1
Dim y = y0 + rowIndex * rowHeight
'Print at y.
Next