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 7th, 2007, 08:07 AM
Authorized User
 
Join Date: Jun 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default print data as receipt format

Hi all,

I need your help. I need to print data as receipt format. The receipt has date, title, cashier name ordered menu and the accumulative payment. As I know there is no preformatting printing in doNet so is there a way to overcome that?

Please help


 
Old July 9th, 2007, 04:45 AM
Authorized User
 
Join Date: Dec 2004
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DZukiewicz
Default

unforutantely, you'll have to make your own.

To make right-alignment, use the PadLeft() method.

Code:
public static string LeftAlign(string text, int widthOfLine)
{
    return text.PadRight(' ', widthOfLine);
}

public static string RightAlign(string text, int widthOfLine)
{
    return text.PadLeft(' ', widthOfLine);
}
To centre text, find the width of the text, and do Math.Floor( ( (width_of_line - width_of_text) ) / 2 ) to get the position to start at.

E.g

Code:
private string CentreText(string text, int widthOfLine)
{
     int startPosition = (int)Math.Floor((widthOfLine - text.Length)/2));
     
     StringBuilder blankLine = new StringBuilder( new string(' ', widthOfLine) );
     blankLine.Insert(startPosition, text);

     return blankLine.ToString();
}
I hope this helps,

Dom





Similar Threads
Thread Thread Starter Forum Replies Last Post
printing a receipt abdrabaa C# 1 September 12th, 2007 03:22 AM
print with the same textbox format abdrabaa C# 1 July 9th, 2007 04:53 AM
how to format a diplayed page for print lanita PHP How-To 0 November 6th, 2004 10:40 PM
Return receipt Persits ASPEmail Haroldd Classic ASP Components 1 March 10th, 2004 11:06 AM





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