this is my print document code problem in foreach loop he is not run help me
im using listview for holding data..
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//throw new NotImplementedException();
Graphics graphic = e.Graphics;
Font font = new Font("Arial ", 12);
float fontheight = font.GetHeight();
int startx = 10;
int starty = 10;
int offset = 40;
graphic.DrawString(" Wangoland Coffee Shop", new Font("Courier New", 18), new SolidBrush(Color.Black), startx, starty);
string top = "Item Name".PadRight(30) + "Price".PadRight(30) + "Quantity".PadRight(30) + "Amount";
graphic.DrawString(top, font, new SolidBrush(Color.Black), startx, starty + offset);
offset = offset + (int)FontHeight; //make the spacing consistent
graphic.DrawString("--------------------------------------------------------------------", font, new SolidBrush(Color.Black), startx, starty + offset);
offset = offset + (int)FontHeight + 5; //make the spacing consistent
float totalprice = 0.00f;
string pn = txtProductName.Text;
string ci = txtConfigID.Text;
string p = txtPrice.Text;
string sq = txtSaleQty.Text;
string tm = txtTotalAmount.Text;
// string productline = pn + ci + p + sq + tm;
//graphic.DrawString("." + txtProductName.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startx, starty + offset);
//graphic.DrawString("." + txtPrice.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startx, starty + offset);
//graphic.DrawString("." + txtSaleQty.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startx, starty + offset);
//graphic.DrawString("." + txtSubTotal.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startx, starty + offset);
//problem start here this loop is not run
foreach (ListViewItem item in ListView1.Items)
{
string productDescription = item;
string p1 = item.SubItems[1](item.Length - 6, 6);
string p2 = item.SubItems[2](item.Length - 5, 5);
string p3 = item.SubItems[3](item.Length - 4, 4);
string p4 = item.SubItems[4](item.Length - 3, 3);
string p5 = item.SubItems[5](item.Length - 2, 2);
string productLine = productDescription;
graphic.DrawString(productLine, font, new SolidBrush(Color.Black), startx, starty + offset);
offset = offset + (int)FontHeight + 5; //make the spacing consistent
// graphic.DrawString(productline, font, new SolidBrush(Color.Black), startx, starty + offset);
graphic.DrawString("Rs." + txtSubTotal.Text, new Font("Arial", 12, FontStyle.Regular), Brushes.Black, startx, starty + offset);
offset = offset + (int)FontHeight + 5;
}