提出问题提出问题
 

已答复print more then two pages?

  • 2009年11月2日 20:29snake_rs PL 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     包含代码
    hi!

    i have problem with printing because when i use
    e.hasmorepages =  true;
    then "printing progress" is couting more then 7000 (longer i dident wait) but on al pages is this text...., i tried also in for(i.. ) with pixels with lines listbox.items.count... but i cant find good way to fix this...

    it is all what i have for print from one listbox:
     private void Drukuj_Click(object sender, EventArgs e)
            {
                drukowanie();
            }
    private void drukowanie()
            {
                PrintDocument pd = new PrintDocument();
                PrintDialog pDialog = new PrintDialog();
                pDialog.Document = pd;
                PrintPreviewDialog prevDialog = new PrintPreviewDialog();
                prevDialog.Document = pd;
                pd.PrintPage += new PrintPageEventHandler(Inven_Raport);
                
                if (pDialog.ShowDialog() == DialogResult.OK)
                {
                   // pd.PrintPage += new PrintPageEventHandler(Inven_Raport);
                    pd.Print();
                 }
            }
        
    private void Inven_Raport(object sender, PrintPageEventArgs e)
            {
                int y = 10;
                Graphics g = e.Graphics;
                Font myFont = new Font("Arial", 10);
                for (int i = 0; i < listBox1.Items.Count; i++)
                {
                 g.DrawString(listBox1.Items[i].ToString(), myFont, Brushes.Black, 20, y);
                   y += 25;
                }
                 myFont.Dispose();
             }
    
    please help me

答案

  • 2009年11月3日 19:15JohnWein 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    You set HasMorePages = true when there is one or more pages remaining that have to be printed. You set HasMorePages = false when the last page has printed.

    Your PrintPage handler gets called repeatedly until you set HasMorePages = false. Each time it is called, a new page will be output.


    e.HasMorePages is false when entering the PrintPage event.  No need to set it unless you want another page and then set it to true.

全部回复

  • 2009年11月2日 23:00JohnWein 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    The code you posted should only print 1 page.  Post the code that causes the 2nd page to print.
  • 2009年11月3日 17:18Tergiver 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    You set HasMorePages = true when there is one or more pages remaining that have to be printed. You set HasMorePages = false when the last page has printed.

    Your PrintPage handler gets called repeatedly until you set HasMorePages = false. Each time it is called, a new page will be output.

    http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.printpage.aspx

  • 2009年11月3日 19:15JohnWein 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     已答复

    You set HasMorePages = true when there is one or more pages remaining that have to be printed. You set HasMorePages = false when the last page has printed.

    Your PrintPage handler gets called repeatedly until you set HasMorePages = false. Each time it is called, a new page will be output.


    e.HasMorePages is false when entering the PrintPage event.  No need to set it unless you want another page and then set it to true.
  • 2009年11月4日 16:16snake_rs PL 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     

    hi,
    hmmmmmm
    it still dosent help me...
    can somebody tell me something more?


    thx


    greetings

  • 2009年11月4日 19:37JohnWein 用户奖牌用户奖牌用户奖牌用户奖牌用户奖牌
     
    The code you posted should only print 1 page.  Post the code that causes the 2nd page to print.

    I don't see how the code you posted prints more than 1 page.  There must be other code that you haven't posted that is causing a 2nd page to print.