Im trying to print from a data grid but all I get when I ask to preview or print the data is "System.Data.DataRowView" printed out once for each of the items in the data grid. This is the code I have used but I can't figure out how to make it print the contents:
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
'define the number of copies to print
AllGuestsPrint.PrinterSettings.Copies = 1
'send the print event which will be picked up by 'Reciept_PrintPage below
'This links Button2 to a particular PrintDocument object you would have dragged onto your form.
AllGuestsPrint.Print()
End Sub
Private Sub AllGuestsPrint_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles AllGuestsPrint.PrintPage
'User has clicked on the print button, so setup the string you want to print
'define variables
Dim iText As Integer
Dim AllGuests As String
'initialise output text
AllGuests = ""
For iText = 0 To DataGridView1.DataSource.Count - 1
AllGuests = AllGuests + (DataGridView1.DataSource(iText).ToString())
AllGuests = AllGuests + vbCrLf
Next
'Just for debug purposes, output the receipt variable so you know what will be printed
MsgBox("The Following will be Printed:-" + vbCrLf + vbCrLf + AllGuests)
'print the string
e.Graphics.DrawString(AllGuests, DataGridView1.Font, Brushes.Black, 100, 100)
End Sub
Please help?
xxx