As mentioned in the title I wanted to generate a data report and found this bit of code on microsoft page.


Hoping Im correct,

Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim f As Font = New Font("Vanada", 12)
Dim br As SolidBrush = New SolidBrush(Color.Black)
Dim p As Pen = New Pen(Color.Black)
e.Graphics.DrawString("This is a text.", f, br, 50, 50)
e.Graphics.DrawRectangle(p, 50, 100, 300, 150)

[ Is this the place to Bind the elements from textbox on to the print page? ]
[ If so how is it done? ]

End Sub

For ex:


First I search an employee and the textboxes are populated. Then when I hit the print button, the labels and the data in the textboxes should appear on the print page.

Guess I have specified my problem correctly.

Thank You :)

You could do something like the following:


If you wanted to pull them in from a dataset, you could do something like this:

Dim da As New OleDBDataAdapter("SELECT * FROM myTable",myCon)
Dim ds As New DataSet


If IsNothing(ds.Tables("MyTable")) = False And ds.Tables("MyTable").Rows.Count > 0 Then
   For i = 0 to ds.Tables("MyTable").Rows.Count - 1
       With ds.Tables("MyTable")
           'Just Remember to Increase the Y on the DrawString so that you are not writing everything in one spot.   
       End With
End If