C# 用C语言打印收据#

C# 用C语言打印收据#,c#,graphics,C#,Graphics,您好,我正在尝试打印某笔交易的账单,我已经打印了,但小计正在打印总行。。。谢谢你的帮助。 下面是我的代码 offset = offset + 20; graphics.DrawString("Total : ".PadRight(40) + total.Text, font, new SolidBrush(Color.Black), startX, startY); graphics.DrawString("SubTotal : ".PadRight(4

您好,我正在尝试打印某笔交易的账单,我已经打印了,但小计正在打印总行。。。谢谢你的帮助。 下面是我的代码

    offset = offset + 20;
        graphics.DrawString("Total : ".PadRight(40) + total.Text, font, new SolidBrush(Color.Black), startX, startY);

        graphics.DrawString("SubTotal : ".PadRight(40) + subtotal.Text, font, new SolidBrush(Color.Black), startX, startY);

graphics.DrawString(“小计:”.PadRight(40)+小计。文本、字体、新SolidBrush(Color.Black)、startX、startY)设置为(通过
startY
)在与前一行相同的y坐标处写入

最好按字体高度增加星形。比如:

offset = offset + 20;
graphics.DrawString("Total : ".PadRight(40) + total.Text, font, new SolidBrush(Color.Black), startX, startY);

startY += font.Height;
graphics.DrawString("SubTotal : ".PadRight(40) + subtotal.Text, font, new SolidBrush(Color.Black), startX, startY);
这会将
startY
增加
font.Height
的量,该量为

获取此字体的行距

备注:

行距是两行连续文本的基线之间的垂直距离。因此,行间距包括行之间的空格和字符本身的高度。
startX,startY
似乎您的合计和小计值相同。你的价值观是什么?