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 6975705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:24:10+00:00 2026-05-27T17:24:10+00:00

Suppose that we declared the line below in our program : List<Dictionary<string, string>> list

  • 0

Suppose that we declared the line below in our program :

 List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();

so we want to print each member of this list into a file and in the separate page, but all in one document like MyDoc.xps. How can i do to achieve my end ?

EDIT : My difficulty is that how can i create new page in printing process?

Sorry if it duplicates with other questions, i can’t get my answer in site threads. 😐

  • 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-27T17:24:11+00:00Added an answer on May 27, 2026 at 5:24 pm

    One way that works is the following:

    1. Make the list global class member
    2. Use the PrintDocument class under System.Drawing.Printing and use its PrintPage event to set the pages one by one.

    Sample code:

    private List<Dictionary<string, string>> myList = new List<Dictionary<string, string>>();
    private int pageIndex = 0;
    private void PrintButton_Click(object sender, EventArgs e)
    {
        PrintDocument document = new PrintDocument();
        document.PrintPage += new PrintPageEventHandler(document_PrintPage);
        document.Print();
    }
    
    void document_PrintPage(object sender, PrintPageEventArgs e)
    {
        if (pageIndex >= myList.Count)
        {
            e.HasMorePages = false;
            return;
        }
    
        Dictionary<string, string> curData = myList[pageIndex];
        List<string> lines = new List<string>();
        lines.Add("Items count: " + curData.Count);
        curData.Keys.ToList().ForEach(key =>
        {
            lines.Add(string.Format("Key: {0}, Value: {1}", key, curData[key]));
        });
        e.Graphics.DrawString(string.Join("\n", lines), this.Font, SystemBrushes.WindowText, 0, 0);
        pageIndex++;
        e.HasMorePages = pageIndex < myList.Count;
    }
    

    On every page printed, the document_PrintPage method will be called. As long as you won’t set e.HasMorePages to false, it will keep printing new pages.

    Edit: to force creating .xps file just add those two lines when creating the print document:

    document.PrinterSettings.PrintToFile = true;
    document.PrinterSettings.PrintFileName = "myfile.xps";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

suppose that no bytecode is generated for a program, like in Ruby, Perl, or
Suppose that i have UIView viewLoading declared in .h. and i do not directly
...in other words: let's suppose I have 2 Strings declared as so: String one
Let us suppose we are going to start new project - application that contains
I've got a one line method that resolves a null string to string.Empty which
Suppose that I have a request handler that accepts an argument: key And let
Suppose that I define some class: class Pixel { public: Pixel(){ x=0; y=0;}; int
Suppose that you have to set 12 cookies, would it be better to store
Suppose that there're two types of packet in the chatting server. Those two packets
Suppose that my index has 3 fields: title, x and y. I know one

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.