Print the Selected XML Record

As i had written my last article XML Read & Update Operations in that you can load the XML records into the Text boxes & in this Blog i am showing you that you can print that particular record.
  1. private void btnPrint_Click(object sender, EventArgs e)  
  2. {  
  3.     System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();  
  4.     strText = "Title : " + txtTitle.Text + "\nAuthor First Name : " + txtFName.Text + "\nAuthor Last Name : " + txtLName.Text + "\nPrice : " + txtPrice.Text;  
  5.     printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDoc_PrintPage);  
  6.     printDoc.Print();  
  7. }  
  8.   
  9. private void printDoc_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)  
  10. {  
  11.     e.Graphics.DrawString(strText, this.txtCount.Font, new System.Drawing.SolidBrush(System.Drawing.Color.Black), e.MarginBounds.Left, 0, new System.Drawing.StringFormat());  
  12.     e.HasMorePages = false;  
  13. }  
Depending on the user's selected Record, it will print that selected record.

See Below Images For More Clear view :

Print_Button.png
 
After Selecting a record by using Next Or Previous Button As Shown in the above Image then click on the print button to print that record.

Here I print into the system printer in One Note Send & It looks like below image :

Print.png