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;
}
}
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;
}
}