Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6237551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:03:00+00:00 2026-05-24T11:03:00+00:00

I am having alot of trouble printing a string with the printdocument method. I

  • 0

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)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:03:01+00:00Added an answer on May 24, 2026 at 11:03 am

    What you can do is use a field in the class where your printdocument method lives to store how many records you’ve managed to print so far:

    EDIT: Updated example code to match your situation

    class YourClass {
      private int charactersPrinted = 0;
    
      ...
    
      private void printdocument(object sender, PrintPageEventArgs ev) {
        var charactersDoneThisPage = 
          this.PrintReportStringPart(reportString.Substring(charactersPrinted));
    
        charactersPrinted += charactersDoneThisPage; // Number of characters you managed to print this page
    
        if (charactersPrinted < reportString.Length) {
          ev.HasMorePages = true;
        } else {
          ev.HasMorePages = false;
        }
      }
    
      // Prints the string to the page
      // Returns the number of characters it was actually able to print
      private int PrintReportStringPart(string reportStringPart) {
    
        // Print the reportStringPart however you're already doing it
        //  filling the page
        return charactersDoneThisPage;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having alot of trouble with this stupid struct. I don't see
Hi I'm having a lot of trouble submitting a simple form, I have searched
I have been having a lot of trouble figuring out how I can access
I'm having a lot of trouble writing this regular expression: (?<=\s+|^\s*|\(\s*|\.)(?:item|item1|item2)(?=\s+|\s*$|\s*\)|\.) It works very
I am having a lot of trouble with this basic recursion problem in java;
I am having a lot of trouble using .dbf files. I have an application
I'm having a lot of trouble with the test_modifier method in lablgtk2. I can
Maybe a simple question but I'm having alot of trouble making a button change
Im having some trouble getting on with my first codeigniter project, and i have
I'm having a lot of trouble implementing this deque using a circular array; in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.