I am trying to print from a WinForms application, I am getting the data overlaying on the same page (page 2 and 3 on the same page).
I tried using HasMorePages and all that does is print MANY copies of the overlapped page.

I manually moved all my first page information into a separate print call as I couldn't get rid of the overlay. Currently I get 2 print dialogs due to this.
However, the second call accesses multiple ultraGrids, where I check the row count (plus header) to see if it will fit on the same page, if not I want it to go to the next page and continue from there.

I know I am missing something, but I have no clue what. I have stumped all of the others here in the office as well.

Please help if you can.

Thanks in advance
Rob


Code:
PrintDocument printDocument1 = new PrintDocument();
PrintDocument printDocument2 = new PrintDocument();
PrintPreviewDialog ppdlg = new PrintPreviewDialog();
//Print Button
private void ultraButton13_Click(object sender, EventArgs e)
{
//Print Button
//Separated out page 1 of the document as it has specific formatting and cant get overlay to stop
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
ppdlg.Document = printDocument1;
ppdlg.ShowDialog();

printDocument2.PrintPage += new PrintPageEventHandler(printDocument1_PrintAdditionalPage);
ppdlg.Document = printDocument2;
ppdlg.ShowDialog();
}



private void printDocument1_PrintAdditionalPage(object sender, PrintPageEventArgs e)
{

//sets the font type and size
Font objFont = new Font("Microsoft Sans Serif", 10F);
Pen blackPen = new Pen(Color.Black, 1);
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
float pageHeight = e.PageSettings.PrintableArea.Height;
float fTopMargin = e.MarginBounds.Top;
float lineCount = 1;
float maxlineCount = 63;
float gridCount = 0;
//sets left margin
float fLeftMargin = 25;
//sets right margin
float fRightMargin = e.MarginBounds.Right - 150;
gridCount = ultraGrid1.Rows.Count;
if ( (lineCount + gridCount + 2) > maxlineCount)
{
}
else
{
lineCount += (gridCount + 2);
}
//Print the Food and Construction Logs on Page 2
string textToPrint = "======================================== Food Log ========================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 line
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Period", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Final Storage", objFont, Brushes.Black, fLeftMargin + 200, fTopMargin);
e.Graphics.DrawString("FoodEvents", objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;
foreach (UltraGridRow row in ultraGrid1.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid1.ActiveRow.Cells["Period"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid1.ActiveRow.Cells["FinalStorage"].Text, objFont, Brushes.Black, fLeftMargin + 200, fTopMargin);
e.Graphics.DrawString(ultraGrid1.ActiveRow.Cells["FoodEvents"].Text, objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}

//skip enough lines to fall below image
fTopMargin += objFont.GetHeight() * 2;

gridCount = ultraGrid2.Rows.Count;
if ((lineCount + gridCount + 2) > maxlineCount)
{
fTopMargin = y;
e.HasMorePages = true;
}
else
{
lineCount += (gridCount + 2);
}

textToPrint = "===================================== Construction Log =====================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Period", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Available", objFont, Brushes.Black, fLeftMargin + 200, fTopMargin);
e.Graphics.DrawString("Used", objFont, Brushes.Black, fLeftMargin + 300, fTopMargin);
e.Graphics.DrawString("Construction", objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;

foreach (UltraGridRow row in ultraGrid2.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid2.ActiveRow.Cells["Period"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid2.ActiveRow.Cells["AmountAvailable"].Text, objFont, Brushes.Black, fLeftMargin + 200, fTopMargin);
e.Graphics.DrawString(ultraGrid2.ActiveRow.Cells["AmountUsed"].Text, objFont, Brushes.Black, fLeftMargin + 300, fTopMargin);
e.Graphics.DrawString(ultraGrid2.ActiveRow.Cells["Construction"].Text, objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}

fTopMargin += objFont.GetHeight() * 2;

gridCount = ultraGrid4.Rows.Count;
if ((lineCount + gridCount + 2) > maxlineCount)
{
fTopMargin = y;
e.HasMorePages = true;
}
else
{
lineCount += (gridCount + 2);
}

textToPrint = "===================================== Tiles =====================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Tile", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Date Added", objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString("Note", objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;

foreach (UltraGridRow row in ultraGrid4.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid4.ActiveRow.Cells["TileName"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid4.ActiveRow.Cells["DateAdded"].Text, objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString(ultraGrid4.ActiveRow.Cells["Note"].Text, objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}
fTopMargin += objFont.GetHeight() * 2;

gridCount = ultraGrid3.Rows.Count;
if ((lineCount + gridCount + 2) > maxlineCount)
{
fTopMargin = y;
e.HasMorePages = true;
}
else
{
lineCount += (gridCount + 2);
}

textToPrint = "===================================== Improvements =====================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Improvement", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Date Added", objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString("Note", objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;

foreach (UltraGridRow row in ultraGrid3.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid3.ActiveRow.Cells["Improvement"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid3.ActiveRow.Cells["DateAdded"].Text, objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString(ultraGrid3.ActiveRow.Cells["Note"].Text, objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}
fTopMargin += objFont.GetHeight() * 2;

gridCount = ultraGrid6.Rows.Count;
if ((lineCount + gridCount + 2) > maxlineCount)
{
fTopMargin = y;
e.HasMorePages = true;
}
else
{
lineCount += (gridCount + 2);
}

textToPrint = "===================================== Buildings =====================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Building", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Date Added", objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString("Note", objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;

foreach (UltraGridRow row in ultraGrid6.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid6.ActiveRow.Cells["Building"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid6.ActiveRow.Cells["DateAdded"].Text, objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString(ultraGrid6.ActiveRow.Cells["Note"].Text, objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}
fTopMargin += objFont.GetHeight() * 2;

gridCount = ultraGrid5.Rows.Count;
if ((lineCount + gridCount + 2) > maxlineCount)
{
fTopMargin = y;
e.HasMorePages = true;
}
else
{
lineCount += (gridCount + 2);
}

textToPrint = "===================================== Infrastructure =====================================";
e.Graphics.DrawString(textToPrint, objFont, Brushes.Black, fLeftMargin, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
//Create Header Row
e.Graphics.DrawString("Improvement", objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString("Date Added", objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString("Note", objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip two lines
fTopMargin += objFont.GetHeight() * 2;

foreach (UltraGridRow row in ultraGrid5.Rows)
{
row.Activate();
row.Selected = true;
e.Graphics.DrawString(ultraGrid5.ActiveRow.Cells["Improvement"].Text, objFont, Brushes.Black, fLeftMargin, fTopMargin);
e.Graphics.DrawString(ultraGrid5.ActiveRow.Cells["DateAdded"].Text, objFont, Brushes.Black, fLeftMargin + 400, fTopMargin);
e.Graphics.DrawString(ultraGrid5.ActiveRow.Cells["Note"].Text, objFont, Brushes.Black, fLeftMargin + 500, fTopMargin);
//skip 1 lines
fTopMargin += objFont.GetHeight();
}
e.HasMorePages = false;

}