print more then two pages?
- hi!
i have problem with printing because when i usee.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:
please help meprivate 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(); }
答案
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.- 已标记为答案snake_rs PL 2009年11月4日 16:14
全部回复
- The code you posted should only print 1 page. Post the code that causes the 2nd page to print.
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.aspxYou 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.- 已标记为答案snake_rs PL 2009年11月4日 16:14
hi,
hmmmmmm
it still dosent help me...
can somebody tell me something more?
thx
greetingsThe 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.

