Click here to Skip to main content
15,922,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a couple of textboxes on my windows form that are written in C#. I am printing the data that are inside of the textboxes using the PrinDocument control and the PrintDialog.

I have written the following code to print a document.

 private void btnPrint_Click(object sender, EventArgs e)
{
DialogResult result = printdlg.ShowDialog();
           if (result == DialogResult.OK)
           {
               docPrint.Print();
           }}



// Print Page event on the Print Document Dialog
C#
private void docPrint_PrintPage(object sender, PrintPageEventArgs e)
       {
frmAdminTermDetails frmUpdateDetails = new frmAdminTermDetails();

e.Graphics.DrawString("TerminalID" + this.strterminalID, 
frmUpdateDetails.txtUpdterminalID.Font, Brushes.Black, 100, 100);

e.Graphics.DrawString("Sim Number:" + this.strSimnr, frmUpdateDetails.txtSimnr.Font, Brushes.Black, 100, 100);
         }



The document is Printing, but the printer is printing all the the data in one line. The data is printing over each other.

What must I change so that each line print underneath each other?

Regards
Posted
Updated 27-Mar-12 3:30am
v2

1 solution

I figured it out. The X and Y coordinates must change

SQL
e.Graphics.DrawString("TerminalID" + this.strterminalID,
frmUpdateDetails.txtUpdterminalID.Font, Brushes.Black, 100, 100);

e.Graphics.DrawString("Sim Number:" + this.strSimnr, frmUpdateDetails.txtSimnr.Font, Brushes.Black, 100, 120);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900