Bharathi Raja

Bharathi Raja

  • NA
  • 1.1k
  • 51.4k

How to Print Multi Pages in C# windows forms

Jun 11 2018 5:40 AM
hai
First 50 values print one page other 50 values not Print 
 
Next page print in other values new page print ..
 
..This is my code
  1. .  private void A5_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)  
  2.         {  
  3.             Font cash = new Font("Arial", 10, FontStyle.Bold);  
  4.             Font bill_no = new Font("Arial", 8, FontStyle.Bold);  
  5.             Font shf1 = new Font("Arial", 8, FontStyle.Regular);  
  6.             Font shf2 = new Font("Arial", 8, FontStyle.Italic);  
  7.             Font shf3 = new Font("Arial", 8, FontStyle.Bold);  
  8.             Font items = new Font("Arial", 8, FontStyle.Regular);  
  9.             Font item_head = new Font("Arial", 10, FontStyle.Regular);  
  10.             Font line = new Font("Arial", 8, FontStyle.Regular);  
  11.             Font tax = new Font("Arial", 6, FontStyle.Regular);  
  12.             Font title = new Font("Arial", 18, FontStyle.Bold);  
  13.             Font address = new Font("Arial", 10, FontStyle.Bold);  
  14.             Font item_eng1 = new Font("Arial", 8, FontStyle.Regular);  
  15.             Font item_tamil1 = new Font("Arial", 8, FontStyle.Regular);  
  16.             int i = 50;  
  17.             e.Graphics.DrawString("S.No", item_head, Brushes.Black, 20, i);  
  18.             e.Graphics.DrawString("NAME", item_head, Brushes.Black, 100, i);  
  19.             e.Graphics.DrawString("MOBILE", item_head, Brushes.Black, 200, i);  
  20.             e.Graphics.DrawString("EMAIL", item_head, Brushes.Black, 350, i);  
  21.             e.Graphics.DrawString("COMPANY", item_head, Brushes.Black, 450, i);  
  22.             e.Graphics.DrawString("BALANCE", item_head, Brushes.Black, 550, i);  
  23.             e.Graphics.DrawString("ADDRESS", item_head, Brushes.Black, 650, i);  
  24.             //e.Graphics.DrawString("QTY", item_head, Brushes.Black, 650, i);  
  25.             //e.Graphics.DrawString("QTY", item_head, Brushes.Black, 750, i);  
  26.             //e.Graphics.DrawString("TAX", item_head, Brushes.Black, 820, i);  
  27.   
  28.             i = i + 15;  
  29.   
  30.             e.Graphics.DrawString("--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", SystemFonts.DefaultFont, Brushes.Black, 20, i);  
  31.             i = i + 15;  
  32.             double qty = 0.00, tax1 = 0, rate = 0.00, tot_qty = 0.00, price = 0;  
  33.             string bal = "", name = "", tax2,ADD,mob,mail,com;  
  34.             int s_no;  
  35.             Rectangle rect_right = new Rectangle();  
  36.             StringFormat str_right = new StringFormat();  
  37.             str_right.LineAlignment = StringAlignment.Near;  
  38.             int line_no = 0;  
  39.             for (int ct = line_no; ct < list_customer_grid.Rows.Count; ct++)  
  40.             {  
  41.   
  42.                 s_no = ct + 1;  
  43.                 name = list_customer_grid.Rows[ct].Cells[2].Value.ToString();  
  44.                 mob = list_customer_grid.Rows[ct].Cells[3].Value.ToString();  
  45.                 mail = list_customer_grid.Rows[ct].Cells[4].Value.ToString() ;  
  46.                 com = list_customer_grid.Rows[ct].Cells[5].Value.ToString();  
  47.                 bal = list_customer_grid.Rows[ct].Cells[6].Value.ToString();  
  48.                 ADD = list_customer_grid.Rows[ct].Cells[8].Value.ToString();  
  49.   
  50.                 str_right.Alignment = StringAlignment.Near;  
  51.                 rect_right = new Rectangle(20, i, 135, 20);  
  52.                 e.Graphics.DrawString(string.Format("{0}", s_no), items, Brushes.Black, rect_right, str_right);  
  53.   
  54.                 str_right.Alignment = StringAlignment.Near;  
  55.                 rect_right = new Rectangle(100, i, 135, 20);  
  56.                 e.Graphics.DrawString(string.Format("{0}", name), items, Brushes.Black, rect_right, str_right);  
  57.   
  58.                 str_right.Alignment = StringAlignment.Near;  
  59.                 rect_right = new Rectangle(200, i, 135, 20);  
  60.                 e.Graphics.DrawString(string.Format("{0}", mob), items, Brushes.Black, rect_right, str_right);  
  61.               //  i = i + 5;  
  62.   
  63.                 str_right.Alignment = StringAlignment.Near;  
  64.                 rect_right = new Rectangle(300, i, 135, 40);  
  65.                 e.Graphics.DrawString(string.Format("{0}", mail), items, Brushes.Black, rect_right, str_right);  
  66.                 i = i + 5;  
  67.                 str_right.Alignment = StringAlignment.Near;  
  68.                 rect_right = new Rectangle(450, i, 135,40);  
  69.                 e.Graphics.DrawString(string.Format("{0}", com), items, Brushes.Black, rect_right, str_right);  
  70.                 i = i + 5;  
  71.                 str_right.Alignment = StringAlignment.Near;  
  72.                 rect_right = new Rectangle(580, i, 135, 20);  
  73.                 e.Graphics.DrawString(string.Format("{0}", bal), items, Brushes.Black, rect_right, str_right);  
  74.   
  75.                 str_right.Alignment = StringAlignment.Near;  
  76.                 rect_right = new Rectangle(650, i, 135, 20);  
  77.                 e.Graphics.DrawString(string.Format("{0}", ADD), items, Brushes.Black, rect_right, str_right);  
  78.               //  e.HasMorePages = true;  
  79.   
  80.                 i = i + 10;  
  81.               
  82.                  
  83.             }  
  84.            
  85.         }  
  86.   
  87.   
  88.         private void button3_Click(object sender, EventArgs e)  
  89.         {  
  90.             if (list_customer_grid.Rows.Count != 0)  
  91.             {  
  92.                 A5.PrintController = new System.Drawing.Printing.StandardPrintController();  
  93.                 A5.PrinterSettings.PrinterName = Global_Class.printer_name;  
  94.                 A5.DefaultPageSettings.PaperSize.RawKind = 512;  
  95.                 A5.Print();  
  96.                           
  97.               
  98.                 //PrintDocument pd = new PrintDocument();  
  99.                 //pd.PrintPage += new PrintPageEventHandler(A5_PrintPage);  
  100.                 //pd.Print();  
  101.                 
  102.             }  
  103.             else  
  104.             {  
  105.                 MessageBox.Show("Complete all detailes""Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);  
  106.             }  
  107.           
  108.             
  109.         }  
 

Answers (3)