我想在收据中放入textbox5的值(含Total :)。收货时,我正在使用DGV打印机。这里的代码,
private void button3_Click(object sender, EventArgs e)
{
DGVPrinter printer = new DGVPrinter();
printer.Title = "Arsalan's Shop";
printer.SubTitle = string.Format("Date : {0}", DateTime.Now.Date.ToString("dd/MM/yyyy"));
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "Developed by Shehrooz !";
printer.FooterSpacing = 15;
printer.PrintDataGridView(dataGridView1);
}
您是否已查看此DGVPrinter的源代码或文档?可用:此处https://www.codeproject.com/Articles/18042/Another-DataGridView-Printer。
文档指出使用此组件有三种方法。您选择了最简单的形式,并且可能希望通过选择更复杂的收据打印方法来自己处理打印。由于textbox5中的总数不是数据网格的一部分,因此您将必须执行自定义打印。实现一个CellOwnerDrawEventHandler,它将允许您控制显示。在CodeProject上下载文档以获取有关完成此示例的更多详细信息:
DGVPrinter printer = new DVGPrinter ();
print.OwnerDraw += new CellOwnerDrawEventHandler(print_OwnerDraw);
print.RowHeight = DGVPrinter.RowHeightSetting.CellHeight;
// Draw column headers upside down and backwards
public void OwnerDraw(object sender, DGVCellDrawingEventArgs e)
{
...
}