2016-06-01 49 views
0

我試圖在不同的頁面中打印不同的數據。如何在C#的不同頁面中打印不同的數據#

ex: - abc,xys,123 =不同的數據。

現在我想在一個頁面上打印abc。 xyz在第二頁。 123在另一個頁面。 普萊舍幫助我FRINDS

我用這個代碼打印一個記錄

private void button1_Click(object sender, EventArgs e) 
    { 
     printDialog1.Document = printDocument1; 
     DialogResult result = printDialog1.ShowDialog(); 
     { 
      if (result == DialogResult.OK) 
      { 
       printDocument1.PrintPage += new PrintPageEventHandler(this.document_PrintPage); 
       printDocument1.Print(); 
      } 


     } 

    } 
    // private System.Drawing.Printing.PrintDocument printDocument1 = new System.Drawing.Printing.PrintDocument(); 

    // The PrintDialog will print the document 
    // by handling the document's PrintPage event. 
    private void document_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) 
    { 

     // Insert code to render the page here.This code will be called when the control is drawn. 

     // The following code will render a simple message on the printed document. 


     System.Drawing.Font printFont = new System.Drawing.Font("Arial", 14, System.Drawing.FontStyle.Regular); 

     // Draw the content. 
     e.Graphics.DrawString((name + "\n" + address + "\n" + address2 + "\n" + address3).ToString(), printFont, System.Drawing.Brushes.Black, 500, 300); 
    } 

回答

相關問題