HasMorePages = true doesn't let me jump to next page

L

Leo

I set HasMorePages to true, but it doesn't let me jump to next page.
(Of course, if I remove the HasMorePages = false in my if statement, it
will create hundreds of pages). Any suggestion? Thanks in advance.

Leo

My code to call the print event:

....
{
m_PrintDoc = new PrintDocument();
m_PrintDoc.PrintPage += new
PrintPageEventHandler(this.OnPrintPage);
m_PrintDoc.DefaultPageSettings.Landscape = false;
m_PrintDoc.DocumentName = "Wall Layout";

m_Preview = new PrintPreviewDialog();
((Form)m_Preview).WindowState = FormWindowState.Maximized;
m_Preview.Document = m_PrintDoc;
m_Preview.ShowDialog();
m_Preview.Dispose();

...
}

private void OnPrintPage(object sender,PrintPageEventArgs e)
{

ArrayList lumberList = m_Wall.GetLumberListBySize();
for (int i = 0; i < lumberList.Count; i++)
{
if (m_yPos > m_BottomMargin)
{
m_yPos = m_TopMargin;
e.HasMorePages = true;
}
else
e.HasMorePages = false;
...
}
}
 
B

Bruce Wood

What do you mean "doesn't let [you] jump to the next page"? You're the
one who controls which page is printed when OnPrintPage is called. I
can't really tell from your code, but I'm guessing that the problem is
that you're getting the list of things to print and starting to loop
through it in your OnPrintPage method, so every time the method is
called you start again at the beginning.

You should do things like get the list of things to print and reset
your "loop" counter in OnBeginPrint. OnPrintPage should start printing
from where it left off last time it was called.

There is no magic "jump to next page"... you have to handle that
yourself.
 
F

Fabio

I set HasMorePages to true, but it doesn't let me jump to next page.
(Of course, if I remove the HasMorePages = false in my if statement, it
will create hundreds of pages). Any suggestion? Thanks in advance.

e.HasMorePages just does what it means: tell if the document has more pages
to be printed.

When you exit from the method you reached the "jump to next page" (of cours,
if the document HasMorePages).
 

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