Printing problems

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2006
Posts: 2
Reputation: Raudhah is an unknown quantity at this point 
Solved Threads: 0
Raudhah Raudhah is offline Offline
Newbie Poster

Printing problems

 
0
  #1
Jan 31st, 2006
Hi. I'm trying to create a program that prints an invoice with multiple pages continuously. Currently, the program allows to print multiple pages but it is exactly the same content from the first page. How can i print in multiple pages and it continues from the first page?

private void DrawAll(System.Drawing.Printing.PrintPageEventArgs e, int controlnum)
{
//RectangleF srcRect = new Rectangle(0, 0, this.Width,
// LargerImage.Height);

Graphics g = e.Graphics;

//e.HasMorePages = true;

RectangleF srcRect = new Rectangle(0, 0, this.BackgroundImage.Width,
BackgroundImage.Height);


int nWidth = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Width;
int nHeight = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Height;
RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight);

g.DrawImage(this.BackgroundImage, destRect, srcRect, GraphicsUnit.Pixel);
// g.DrawImage(this.LargerImage, destRect, srcRect, GraphicsUnit.Pixel);

float scalex = destRect.Width/this.BackgroundImage.Width;
float scaley = destRect.Height/this.BackgroundImage.Height;

Pen aPen = new Pen(Brushes.Black, 1);

float ypos = 0;
string name = "HATLAPA";
string name2 = "A S I A P A C I F I C P T E L T D";
string CompanyAddress1 = "25 International Business Park, #02-25 German Centre";
string CompanyAddress2 = "Singapore 609916. Tel65) 65628088 Fax65)65628099";
Font f = new Font("Arial Black", 24);
Font f2 = new Font("Times New Roman", 14,FontStyle.Bold);
Font f3 = new Font("Arial",10);

g.DrawString(name, f, Brushes.Black, scalex + 320, scaley - 10 , new StringFormat());
g.DrawString(name2, f2, Brushes.Black, scalex + 266, scaley + 26, new StringFormat());
g.DrawString(CompanyAddress1, f3, Brushes.Black, scalex + 232, scaley + 56, new StringFormat());
g.DrawString(CompanyAddress2, f3, Brushes.Black, scalex + 227, scaley + 75, new StringFormat());


for (int i = controlnum; i < this.Controls.Count; i++)
{
// draw logo
//if (Controls[i].GetType() == this.pictureBox1.GetType())
//{
// if (pictureBox1.Image != null)
// {
// GraphicsUnit gu = GraphicsUnit.Pixel;
// RectangleF scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox1.Bounds);
// Image myImage = (Image)pictureBox1.Image.Clone();
// g.DrawImage(myImage, scaledRectangle, pictureBox1.Image.GetBounds(ref gu), GraphicsUnit.Pixel);
// }
//}

// print edit box control contents
if (Controls[i].GetType() == this.textBox1.GetType())
{
if (!ControlIsListViewEdit(i)) // skip these
{
TextBox theText = (TextBox)Controls[i];
if (theText.Name == "SubtotalTextBox" )
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j+1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 135;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left*scalex + 25, ypos * scaley, new StringFormat());
}
else if (theText.Name == "PercentTextBox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 155;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}
else if (theText.Name == "SPPTextBox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 175;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());

}

else if (theText.Name == "TotalTextBox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 195;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}
else if (theText.Name == "paymentTermTextbox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 255;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}

else if (theText.Name == "tiemeDeliveryTextbox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 235;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}
else if (theText.Name == "validityTextbox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 285;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}

else if (theText.Name == "termofPriceTextbox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley +305;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());

}
else if (theText.Name == "remarkTextbox")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 325;
break;
}
}
}

g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());

}

else
g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 35, theText.Bounds.Top * scaley + 115, new StringFormat());
}


}

// handle date controls
if (Controls[i].GetType() == this.TodayPicker.GetType())
{
DateTimePicker aPicker = (DateTimePicker)Controls[i];
g.DrawString(aPicker.Text, aPicker.Font, Brushes.Black, aPicker.Bounds.Left*scalex +35, aPicker.Bounds.Top * scaley + 115, new StringFormat());
}

if (Controls[i].GetType() == this.label1.GetType())
{
Label l = (Label)Controls[i];
if (l.Name == "lblSubtotal")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 135;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}
else if (l.Name == "lblDiscount")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley +155;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}

else if (l.Name == "lblDiscountedPrice")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 175;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}
else if (l.Name == "lblGrandtotal")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 195;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}
else if (l.Name == "lblTimeOfDelivery")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 235;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
}

else if (l.Name == "lblPaymentTerm")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 255;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());

}
else if (l.Name == "lblValidity")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 285;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}

else if (l.Name == "lblTermOfPrice")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 305;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}
else if (l.Name == "lblRemarks")
{
for (int j = 0; j < listView1.Items.Count; j++)
{
if (listView1.Items[j].Text == "")
{
if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
{
ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 325;
break;
}
}
}

g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());


}



else
{
g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 35, l.Bounds.Top * scaley + 115, new StringFormat());
}

}


// handle List View Control
if (Controls[i].GetType() == this.listView1.GetType())
{
for (int row = 0; row < listView1.Items.Count; row++)
{
int nextColumnPosition = listView1.Bounds.X;
for (int col = 0; col < listView1.Items[row].SubItems.Count; col++)
{
g.DrawString(listView1.Items[row].SubItems[col].Text, listView1.Items[row].Font, Brushes.Black, (nextColumnPosition + 3)*scalex + 35 , (listView1.Items[row].Bounds.Y + listView1.Bounds.Y)* scaley+115, new StringFormat());
nextColumnPosition += listView1.Columns[col].Width;

}
}

}




// if (Controls[i].GetType() == this.RetirementPlanCheck.GetType())
// {
// CheckBox theCheck = (CheckBox)Controls[i];
// Rectangle aRect = theCheck.Bounds;
// g.DrawRectangle(aPen, aRect.Left*scalex, aRect.Top*scaley, aRect.Width*scalex, aRect.Height*scaley);
// if (theCheck.Checked)
// {
// g.DrawString("x", theCheck.Font, Brushes.Black,
// theCheck.Left*scalex + 1, theCheck.Top*scaley + 1, new StringFormat());
// }
// }


if (i == 10)
{
controlnum = i;
e.HasMorePages = true;

}
} // end for loop

// if ypos near the page margin,
// e.hasMorePages = true;



}
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 206
Reputation: plazmo is an unknown quantity at this point 
Solved Threads: 16
plazmo's Avatar
plazmo plazmo is offline Offline
Posting Whiz in Training

Re: Printing problems

 
0
  #2
Feb 6th, 2006
please put that code between code tags. id like to help you much its hard to read like that
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 2
Reputation: Raudhah is an unknown quantity at this point 
Solved Threads: 0
Raudhah Raudhah is offline Offline
Newbie Poster

Re: Printing problems

 
0
  #3
Feb 6th, 2006
  1. private void DrawAll(System.Drawing.Printing.PrintPageEventArgs e, int controlnum)
  2. {
  3. //RectangleF srcRect = new Rectangle(0, 0, this.Width,
  4. // LargerImage.Height);
  5.  
  6. Graphics g = e.Graphics;
  7.  
  8. //e.HasMorePages = true;
  9.  
  10. RectangleF srcRect = new Rectangle(0, 0, this.BackgroundImage.Width,
  11. BackgroundImage.Height);
  12.  
  13.  
  14. int nWidth = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Width;
  15. int nHeight = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Height;
  16. RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight);
  17.  
  18. g.DrawImage(this.BackgroundImage, destRect, srcRect, GraphicsUnit.Pixel);
  19. // g.DrawImage(this.LargerImage, destRect, srcRect, GraphicsUnit.Pixel);
  20.  
  21. float scalex = destRect.Width/this.BackgroundImage.Width;
  22. float scaley = destRect.Height/this.BackgroundImage.Height;
  23.  
  24. Pen aPen = new Pen(Brushes.Black, 1);
  25.  
  26. float ypos = 0;
  27. string name = "HATLAPA";
  28. string name2 = "A S I A P A C I F I C P T E L T D";
  29. string CompanyAddress1 = "25 International Business Park, #02-25 German Centre";
  30. string CompanyAddress2 = "Singapore 609916. Tel:(65) 65628088 Fax:(65)65628099";
  31. Font f = new Font("Arial Black", 24);
  32. Font f2 = new Font("Times New Roman", 14,FontStyle.Bold);
  33. Font f3 = new Font("Arial",10);
  34.  
  35. g.DrawString(name, f, Brushes.Black, scalex + 320, scaley - 10 , new StringFormat());
  36. g.DrawString(name2, f2, Brushes.Black, scalex + 266, scaley + 26, new StringFormat());
  37. g.DrawString(CompanyAddress1, f3, Brushes.Black, scalex + 232, scaley + 56, new StringFormat());
  38. g.DrawString(CompanyAddress2, f3, Brushes.Black, scalex + 227, scaley + 75, new StringFormat());
  39.  
  40.  
  41. for (int i = controlnum; i < this.Controls.Count; i++)
  42. {
  43. // draw logo
  44. //if (Controls[i].GetType() == this.pictureBox1.GetType())
  45. //{
  46. // if (pictureBox1.Image != null)
  47. // {
  48. // GraphicsUnit gu = GraphicsUnit.Pixel;
  49. // RectangleF scaledRectangle = GetScaledRectangle(scalex, scaley, pictureBox1.Bounds);
  50. // Image myImage = (Image)pictureBox1.Image.Clone();
  51. // g.DrawImage(myImage, scaledRectangle, pictureBox1.Image.GetBounds(ref gu), GraphicsUnit.Pixel);
  52. // }
  53. //}
  54.  
  55. // print edit box control contents
  56. if (Controls[i].GetType() == this.textBox1.GetType())
  57. {
  58. if (!ControlIsListViewEdit(i)) // skip these
  59. {
  60. TextBox theText = (TextBox)Controls[i];
  61. if (theText.Name == "SubtotalTextBox" )
  62. {
  63. for (int j = 0; j < listView1.Items.Count; j++)
  64. {
  65. if (listView1.Items[j].Text == "")
  66. {
  67. if (j < listView1.Items.Count - 1 && listView1.Items[j+1].Text == "")
  68. {
  69. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 135;
  70. break;
  71. }
  72. }
  73. }
  74.  
  75. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left*scalex + 25, ypos * scaley, new StringFormat());
  76. }
  77. else if (theText.Name == "PercentTextBox")
  78. {
  79. for (int j = 0; j < listView1.Items.Count; j++)
  80. {
  81. if (listView1.Items[j].Text == "")
  82. {
  83. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  84. {
  85. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 155;
  86. break;
  87. }
  88. }
  89. }
  90.  
  91. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  92. }
  93. else if (theText.Name == "SPPTextBox")
  94. {
  95. for (int j = 0; j < listView1.Items.Count; j++)
  96. {
  97. if (listView1.Items[j].Text == "")
  98. {
  99. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  100. {
  101. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 175;
  102. break;
  103. }
  104. }
  105. }
  106.  
  107. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  108.  
  109. }
  110.  
  111. else if (theText.Name == "TotalTextBox")
  112. {
  113. for (int j = 0; j < listView1.Items.Count; j++)
  114. {
  115. if (listView1.Items[j].Text == "")
  116. {
  117. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  118. {
  119. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 195;
  120. break;
  121. }
  122. }
  123. }
  124.  
  125. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  126.  
  127.  
  128. }
  129. else if (theText.Name == "paymentTermTextbox")
  130. {
  131. for (int j = 0; j < listView1.Items.Count; j++)
  132. {
  133. if (listView1.Items[j].Text == "")
  134. {
  135. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  136. {
  137. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 255;
  138. break;
  139. }
  140. }
  141. }
  142.  
  143. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  144.  
  145.  
  146. }
  147.  
  148. else if (theText.Name == "tiemeDeliveryTextbox")
  149. {
  150. for (int j = 0; j < listView1.Items.Count; j++)
  151. {
  152. if (listView1.Items[j].Text == "")
  153. {
  154. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  155. {
  156. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 235;
  157. break;
  158. }
  159. }
  160. }
  161.  
  162. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  163.  
  164.  
  165. }
  166. else if (theText.Name == "validityTextbox")
  167. {
  168. for (int j = 0; j < listView1.Items.Count; j++)
  169. {
  170. if (listView1.Items[j].Text == "")
  171. {
  172. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  173. {
  174. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 285;
  175. break;
  176. }
  177. }
  178. }
  179.  
  180. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  181.  
  182.  
  183. }
  184.  
  185. else if (theText.Name == "termofPriceTextbox")
  186. {
  187. for (int j = 0; j < listView1.Items.Count; j++)
  188. {
  189. if (listView1.Items[j].Text == "")
  190. {
  191. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  192. {
  193. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley +305;
  194. break;
  195. }
  196. }
  197. }
  198.  
  199. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  200.  
  201. }
  202. else if (theText.Name == "remarkTextbox")
  203. {
  204. for (int j = 0; j < listView1.Items.Count; j++)
  205. {
  206. if (listView1.Items[j].Text == "")
  207. {
  208. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  209. {
  210. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 325;
  211. break;
  212. }
  213. }
  214. }
  215.  
  216. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  217.  
  218. }
  219.  
  220. else
  221. g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left * scalex + 35, theText.Bounds.Top * scaley + 115, new StringFormat());
  222. }
  223.  
  224.  
  225. }
  226.  
  227. // handle date controls
  228. if (Controls[i].GetType() == this.TodayPicker.GetType())
  229. {
  230. DateTimePicker aPicker = (DateTimePicker)Controls[i];
  231. g.DrawString(aPicker.Text, aPicker.Font, Brushes.Black, aPicker.Bounds.Left*scalex +35, aPicker.Bounds.Top * scaley + 115, new StringFormat());
  232. }
  233.  
  234. if (Controls[i].GetType() == this.label1.GetType())
  235. {
  236. Label l = (Label)Controls[i];
  237. if (l.Name == "lblSubtotal")
  238. {
  239. for (int j = 0; j < listView1.Items.Count; j++)
  240. {
  241. if (listView1.Items[j].Text == "")
  242. {
  243. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  244. {
  245. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 135;
  246. break;
  247. }
  248. }
  249. }
  250.  
  251. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  252. }
  253. else if (l.Name == "lblDiscount")
  254. {
  255. for (int j = 0; j < listView1.Items.Count; j++)
  256. {
  257. if (listView1.Items[j].Text == "")
  258. {
  259. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  260. {
  261. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley +155;
  262. break;
  263. }
  264. }
  265. }
  266.  
  267. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  268. }
  269.  
  270. else if (l.Name == "lblDiscountedPrice")
  271. {
  272. for (int j = 0; j < listView1.Items.Count; j++)
  273. {
  274. if (listView1.Items[j].Text == "")
  275. {
  276. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  277. {
  278. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 175;
  279. break;
  280. }
  281. }
  282. }
  283.  
  284. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  285. }
  286. else if (l.Name == "lblGrandtotal")
  287. {
  288. for (int j = 0; j < listView1.Items.Count; j++)
  289. {
  290. if (listView1.Items[j].Text == "")
  291. {
  292. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  293. {
  294. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 195;
  295. break;
  296. }
  297. }
  298. }
  299.  
  300. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  301. }
  302. else if (l.Name == "lblTimeOfDelivery")
  303. {
  304. for (int j = 0; j < listView1.Items.Count; j++)
  305. {
  306. if (listView1.Items[j].Text == "")
  307. {
  308. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  309. {
  310. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 235;
  311. break;
  312. }
  313. }
  314. }
  315.  
  316. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  317. }
  318.  
  319. else if (l.Name == "lblPaymentTerm")
  320. {
  321. for (int j = 0; j < listView1.Items.Count; j++)
  322. {
  323. if (listView1.Items[j].Text == "")
  324. {
  325. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  326. {
  327. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 255;
  328. break;
  329. }
  330. }
  331. }
  332.  
  333. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  334.  
  335. }
  336. else if (l.Name == "lblValidity")
  337. {
  338. for (int j = 0; j < listView1.Items.Count; j++)
  339. {
  340. if (listView1.Items[j].Text == "")
  341. {
  342. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  343. {
  344. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 285;
  345. break;
  346. }
  347. }
  348. }
  349.  
  350. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  351.  
  352.  
  353. }
  354.  
  355. else if (l.Name == "lblTermOfPrice")
  356. {
  357. for (int j = 0; j < listView1.Items.Count; j++)
  358. {
  359. if (listView1.Items[j].Text == "")
  360. {
  361. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  362. {
  363. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 305;
  364. break;
  365. }
  366. }
  367. }
  368.  
  369. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  370.  
  371.  
  372. }
  373. else if (l.Name == "lblRemarks")
  374. {
  375. for (int j = 0; j < listView1.Items.Count; j++)
  376. {
  377. if (listView1.Items[j].Text == "")
  378. {
  379. if (j < listView1.Items.Count - 1 && listView1.Items[j + 1].Text == "")
  380. {
  381. ypos = (listView1.Items[j].Bounds.Y + listView1.Bounds.Y) * scaley + 325;
  382. break;
  383. }
  384. }
  385. }
  386.  
  387. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 25, ypos * scaley, new StringFormat());
  388.  
  389.  
  390. }
  391.  
  392.  
  393.  
  394. else
  395. {
  396. g.DrawString(l.Text, l.Font, Brushes.Black, l.Bounds.Left * scalex + 35, l.Bounds.Top * scaley + 115, new StringFormat());
  397. }
  398.  
  399. }
  400.  
  401.  
  402. // handle List View Control
  403. if (Controls[i].GetType() == this.listView1.GetType())
  404. {
  405. for (int row = 0; row < listView1.Items.Count; row++)
  406. {
  407. int nextColumnPosition = listView1.Bounds.X;
  408. for (int col = 0; col < listView1.Items[row].SubItems.Count; col++)
  409. {
  410. g.DrawString(listView1.Items[row].SubItems[col].Text, listView1.Items[row].Font, Brushes.Black, (nextColumnPosition + 3)*scalex + 35 , (listView1.Items[row].Bounds.Y + listView1.Bounds.Y)* scaley+115, new StringFormat());
  411. nextColumnPosition += listView1.Columns[col].Width;
  412.  
  413. }
  414. }
  415.  
  416. }
  417.  
  418.  
  419.  
  420.  
  421. // if (Controls[i].GetType() == this.RetirementPlanCheck.GetType())
  422. // {
  423. // CheckBox theCheck = (CheckBox)Controls[i];
  424. // Rectangle aRect = theCheck.Bounds;
  425. // g.DrawRectangle(aPen, aRect.Left*scalex, aRect.Top*scaley, aRect.Width*scalex, aRect.Height*scaley);
  426. // if (theCheck.Checked)
  427. // {
  428. // g.DrawString("x", theCheck.Font, Brushes.Black,
  429. // theCheck.Left*scalex + 1, theCheck.Top*scaley + 1, new StringFormat());
  430. // }
  431. // }
  432.  
  433.  
  434. if (i == 10)
  435. {
  436. controlnum = i;
  437. e.HasMorePages = true;
  438.  
  439. }
  440. } // end for loop
  441.  
  442. // if ypos near the page margin,
  443. // e.hasMorePages = true;
  444.  
  445.  
  446.  
  447. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC