I am having alot of trouble printing a string with the printdocument method.
I have a report of invalid entries in the form of a string. I build this string by concatenating entries to it while inside a forloop of the invalid entries. It looks like this
foreach(Error entry in ErrorEntries)
reportString += entry.ToString();
Now I access this string from the printdocument method (it’s a singleton). The trouble is that the string has about 300 entries so does not fit onto one page.
Let’s say it prints the first 30 records. I am having trouble with the e.HasMorePages = true command as from what I understand, it reruns the rpintdocument1 method. If that’s the case, then the method will just print the reportstring from top to bottom again stopping at the 30th record.
Is there a way to delete the line I just printed from the reportSummary string so the next time the printdocument method runs, it’s not printing the same contents of the string (the beginning 30 records)?
What you can do is use a field in the class where your
printdocumentmethod lives to store how many records you’ve managed to print so far:EDIT: Updated example code to match your situation