Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 4th, 2007, 12:51 AM
Authorized User
Join Date: Jun 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default print with the same textbox format


I need your help in printing text. I need to print the text with center alignment or at least print the text in the same format shown in the screen (regarding spaces and alignments).
Also, is it possible to print a text by multiple printers?
Old July 9th, 2007, 04:53 AM
Authorized User
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz

I wrote a response to someone earlier regarding alignment.

For left align, use PadRight (placing spaces on the right of the text).
For right align, use PadLeft (placing spaces on the left of the text).


"DATE: 03/05/2006"

PadRight (30):
"DATE: 03/05/2006 "

PadLeft (30):
" DATE: 03/05/2006"

Centering is done by getting the length of the line, the length of the text and finding the start position.

public static string CentreText(string text, int widthOfLine)
     int startPosition = (int)Math.Floor(( width_of_line - text.Length ) / 2);

     StringBuilder str = new StringBuilder( new string(' ' , widthOfLine) );

     return str.ToString();

Similar Threads
Thread Thread Starter Forum Replies Last Post
Textbox problem print preview vs. print jenisageek Access 5 May 2nd, 2008 12:54 PM
TextBox Format prasanna.nadgir C# 4 September 11th, 2007 09:50 AM
print data as receipt format abdrabaa C# 1 July 9th, 2007 04:45 AM
Textbox format sbass .NET Web Services 1 February 28th, 2004 03:32 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.