如何设置收据预付款 [英] How to set receipt alingment

查看:225
本文介绍了如何设置收据预付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我要设置收据对齐方式我的收据对齐方式很脏,我不知道如何设置标准的打印收据对齐方式
请查看我的收据对齐方式

[ ^ ]

我尝试过的事情:

Hello Guys, i want to set my receipt alignment my receipt alignment is to dirty and i dont know how to set standard print receipt alignment
please see my receipt alignment

[^]

What I have tried:

Graphics graphics = e.Graphics;
            Font f = new Font("Arial", 8);
            float fontHeight = f.GetHeight();
            int starto = 30;
            int startp = 6;
            int startoo = 180;
            int startpp = 9;
            int startX = 10;
            int startY = 10;
            int offset = 40;
            int offset1 = 260;
            int offset2 = 280;
            int line = 1;
            int line1 = 5;
            int line2 = 6;
            int line3 = 24;
            int line4 = 124;
            int line5 = 32;
            int line6 = 20;
            int line7 = 3;
            int line8 = 6;
            int line9 = 32;
            int offset3 = 250;
            int offset4 = 260;
            int offset5 = 270;

            graphics.DrawString(txtDisplay.Text, new Font("Courier New", 6), new SolidBrush(Color.Black), line, line1);
            graphics.DrawString(setaluefortext00001name, new Font("Courier New", 15), new SolidBrush(Color.Black), starto, startp);
            graphics.DrawString("*****************************************************************", new Font("Courier New", 6), new SolidBrush(Color.Black), line2, line3);
            graphics.DrawString(label4.Text, new Font("Courier New", 6), new SolidBrush(Color.Black), line8, line9);
            //graphics.DrawString("Order No: "+ + label2.Text, new Font("Courier New", 6), new SolidBrush(Color.Red), line4, line5);
            foreach (tblProductEx product in products1)
            {
                //for (int z = 0; z < dataGridView2.Rows.Count - 1; z++)
                //{
                    string productDescription = product.productName.PadRight(30);

                    string productTotal = "Rs:" + string.Format("{0:}", product.productPrice);
                    string prodcutLine = productDescription + productTotal;

                    graphics.DrawString(prodcutLine, f, new SolidBrush(Color.Black), startX, startY + offset);

                    offset = offset + (int)fontHeight + 5;
                //}
            }
            offset = offset + 20;
            tblTransaction transaction = new tblTransaction();
            transaction.transactionDate = DateTime.Now;
            graphics.DrawString("Total To Pay".PadRight(15) + "Rs " + string.Format("{0:}", total1), f, new SolidBrush(Color.Black), startX, startY + offset3);
            graphics.DrawString("Thank You For Coming,".PadRight(15) + string.Format(""), f, new SolidBrush(Color.Black), startX, startY + offset4);

推荐答案

报价:

我不知道如何设置标准打印收据对齐方式

i dont know how to set standard print receipt alignment

进行对齐,您只是做错了.

看看您的工作:您在每个tome上绘制一个字符串,并给出坐标以指示左侧部分从何处开始.
对于左侧对齐的标签,只需给出坐标即可.
对于右对齐或居中对齐的标签,您需要查询系统的长度并计算匹配的左坐标.
对于居中标签,左坐标为中心坐标减去长度/2.
对于右标签,左坐标是右坐标减去长度.

You are already doing alignment, you simply do it wrong.

See what you do: each tome you draw a string, you give coordinates which tell where the left part begins.
For label aligned on left, just give coordinates.
For label aligned on right or centered, you need to query the system for the length and compute the matching left coordinate.
for centered label, the left coordinate is center coordinate minus length/2.
for right label, the left coordinate is right coordinate minus length.


这篇关于如何设置收据预付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆