Print the Selected XML Record

Using this code you will know that how to 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.


 private void btnPrint_Click(object sender, EventArgs e)

{

            System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();

            strText = "Title : " + txtTitle.Text + "\nAuthor First Name : " + txtFName.Text + "\nAuthor Last Name : " + txtLName.Text + "\nPrice : " + txtPrice.Text;

            printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDoc_PrintPage);

            printDoc.Print();

}

 

private void printDoc_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)

{

            e.Graphics.DrawString(strText, this.txtCount.Font, new System.Drawing.SolidBrush(System.Drawing.Color.Black), e.MarginBounds.Left, 0, new System.Drawing.StringFormat());

            e.HasMorePages = false;

}


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