Cannot Print more than two pages

B

BVM

Hi, All:

I have a problem with print preview. Even though I set e.HasMorePages = true, it still cannot print 2 pages, I mean content of page 2 is printed in page 1. How do I solve this problem?

Thanks,

Dennis Huang

==== some codes =========
private void PrintCalendar(object sender, System.EventArgs e)

{

this.pagesPrinted = 0;

PrintPreviewDialog ppd = new PrintPreviewDialog();

ppd.Width = this.Width;

ppd.Height = this.Height;

System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();

doc.PrintPage += new PrintPageEventHandler (this.OnPrintPage);

ppd.Document = doc;

ppd.ShowDialog(this);

}

private void OnPrintPage(object sender, PrintPageEventArgs e)

{

float leftMargin = e.MarginBounds.Left;

float topMargin = e.MarginBounds.Top;

float gap = 3;

float yPos;

e.HasMorePages = true;

while (theDate.CompareTo(dtFinish.Value) <= 0)

{

...... print something here

......print something here

......print something here


if (theDate.CompareTo(dtFinish.Value) <= 0)

e.HasMorePages = true;

else

e.HasMorePages = false;

}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top