我在打印帐单时无法正确对齐 [英] I am not getting proper Alignment while printing a bill

查看:77
本文介绍了我在打印帐单时无法正确对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我对.net应用程序非常陌生,
我正在做一个项目,希望在打印时进行正确的对齐,而我却没有.
实际上,我希望我的打印预览像许多购物中心账单(条码,商品名称,价格,数量)一样,都显示在
的正下方 我的代码中所有项目中的所有项目都与众不同.我使用winfrom和access数据库.
请帮帮我.
如何获得对齐方式富文本框
即使我做了很多谷歌搜索,我也热切地等待着我……..

在此先感谢

Hi
I''m very much new to .net application,
I''m doing a project where I want to get proper alignment at print time I''m not getting it.
Actually I want my print preview like many shopping mall bill(barcode,itemname,rate,quantity)all display exactly below
of all item here in my code I''m getting difference in all those item.I''m using winfrom and access database.
Please help me.
How to get alignment Rich textbox
Plz Help me i m eagerly Waiting for it even i did lot of googling........

Thanks in Advance

private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
    //float tempgross = float.Parse(txtsubtotal.Text.Trim());
    Font font = new Font("Verdana", 10);
    Font font2 = new Font("Verdana", 40, FontStyle.Bold);

    float x = e.PageSettings.HardMarginX;
    float y = e.PageSettings.HardMarginY;

    float x1 = (e.PageSettings.Margins.Left = 10);
    float y1 = (e.PageSettings.Margins.Top = 60);

    string longline = "_________________________________";

    string clipinfo = "Date:" + System.DateTime.Now.ToShortDateString() + "" + "\n" + "Time   : " + System.DateTime.Now.ToShortTimeString() + "" + "   " + "Cashier :" + lbluserid.Text + "~" + userid1 + "";
    string Billheadinginfo = "SNo. "   + "Item Name" + "  "   + "Qty" + "  "   + "Rate" +   "    "    + "Amount";
    string Billvalue = "Total                       :                ";// +tempgross;
    string Thanks = "        THANK YOU VISIT AGAIN     ";

    float lineHeight = font.GetHeight(e.Graphics);

    string name = "Quotation";
    for (int i = 0; i < 1; i++)
    {
        e.Graphics.DrawString(name, font2, Brushes.Black, x, y);
        e.Graphics.DrawString("\n" + longline + "\n" + clipinfo + "\n" + longline + "\n" + Billheadinginfo + "\n" + longline + "\n" + richTextBox2.Text + longline + "\n" + Billvalue + "\n" + longline +  "\n" + "\n" + Thanks, font, Brushes.Black, x1, y1);
        y += lineHeight;
    }
    y += lineHeight;
}

推荐答案

您仍然没有确切说明问题所在,但我猜是因为您使用的是比例字体而不是固定宽度类型.尝试使用"Courier New"之类的方法,看看是否可行.
You still have not explained exactly what your problem is but I am guessing it''s because you are using a proportional font rather than a fixed width type. Try something like "Courier New" and see if that works.


这篇关于我在打印帐单时无法正确对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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