I have created a datatable and now i need to print it,so i did the following:
The code works fine.But in the above code as you can see that i am printing the each rows content of the datatable one by one and after printing all the contents of a single row i am looping the code again for printing each and every row present in the datatable.Code:Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim xPos As Single = 20 Dim yPos As Single = 20 Dim i As Integer = 0 For Each rows As DataRow In dt.Rows e.Graphics.DrawString(dt.Rows(i).Item(0).ToString, _detailFont, Brushes.Black, xPos, yPos) xPos += e.Graphics.MeasureString(dt.Rows(i).Item(0).ToString, _detailFont).Width e.Graphics.DrawString(dt.Rows(i).Item(1).ToString, _detailFont, Brushes.Black, xPos, yPos) xPos += e.Graphics.MeasureString(dt.Rows(i).Item(1).ToString, _detailFont).Width e.Graphics.DrawString(dt.Rows(i).Item(2).ToString, _detailFont, Brushes.Black, xPos, yPos) xPos += e.Graphics.MeasureString(dt.Rows(i).Item(2).ToString, _detailFont).Width e.Graphics.DrawString(dt.Rows(i).Item(3).ToString, _detailFont, Brushes.Black, xPos, yPos) xPos = 20 yPos += 20 i += 1 Next End Sub
So i want to know that inspite of printing each and every data present in the row of the datatable,is it possible to print the entire datarow at a time and then loop through all the rows present in the datatable?
Hope you can understand my problem.Please help
Thank you![]()




Reply With Quote