[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

C# Printing many textboxes

Hello Expert I was wondering if you could show me how i can format the information I have to a certain layout I want it to print to the printer this is what i want it too look like

Company Number: 979734    Company Name: Willson   Year:2004
ContactName: Mike Smith

this is what my code looks like

printDialog1.Document = ThePrintDocument;
string strText = "Company Number: " + this.lblProjectNo.Text
       + "Company Name" + this.txtProjectName.Text
      + " Year " + this.txtYear.Text
      + " ContactName " + this.cmbName.Text;

But this does prints all in one line and I don't want it too can you help please.
0
jvoros1
Asked:
jvoros1
  • 2
  • 2
1 Solution
 
JoeisanerdCommented:
Try chaning it to the following


this is what my code looks like

printDialog1.Document = ThePrintDocument;
string strText = "Company Number: " + this.lblProjectNo.Text
      + "Company Name" + this.txtProjectName.Text
     + " Year " + this.txtYear.Text
     + "\r\nContactName " + this.cmbName.Text;

what I added was the \r\n which is the return character and the newline. I put both there because one or the other should do the trick so you can try it with \r and if that doesn't work try \n.
0
 
jvoros1Author Commented:
Thanks so much it worked :)
0
 
jvoros1Author Commented:
just one thing for allignment is there such thing as \t for like tab?
0
 
JoeisanerdCommented:
yes that is right.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now