使用PrintDcument和PrintDialog从文本框中打印数据 [英] Printing data from textboxes using PrintDcument and PrintDialog
本文介绍了使用PrintDcument和PrintDialog从文本框中打印数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的Windows窗体上有几个用C#编写的文本框.我正在使用PrinDocument控件和PrintDialog打印文本框中的数据.
我已经编写了以下代码来打印文档.
I have a couple of textboxes on my windows form that are written in C#. I am printing the data that are inside of the textboxes using the PrinDocument control and the PrintDialog.
I have written the following code to print a document.
private void btnPrint_Click(object sender, EventArgs e)
{
DialogResult result = printdlg.ShowDialog();
if (result == DialogResult.OK)
{
docPrint.Print();
}}
//打印文档"对话框上的打印页面"事件
// Print Page event on the Print Document Dialog
private void docPrint_PrintPage(object sender, PrintPageEventArgs e)
{
frmAdminTermDetails frmUpdateDetails = new frmAdminTermDetails();
e.Graphics.DrawString("TerminalID" + this.strterminalID,
frmUpdateDetails.txtUpdterminalID.Font, Brushes.Black, 100, 100);
e.Graphics.DrawString("Sim Number:" + this.strSimnr, frmUpdateDetails.txtSimnr.Font, Brushes.Black, 100, 100);
}
文档为正在打印",但是打印机正在一行打印所有数据.数据正在相互打印.
我必须更改什么才能使每行打印在彼此下面?
关于
The document is Printing, but the printer is printing all the the data in one line. The data is printing over each other.
What must I change so that each line print underneath each other?
Regards
推荐答案
我知道了. X和Y坐标必须更改
I figured it out. The X and Y coordinates must change
e.Graphics.DrawString("TerminalID" + this.strterminalID,
frmUpdateDetails.txtUpdterminalID.Font, Brushes.Black, 100, 100);
e.Graphics.DrawString("Sim Number:" + this.strSimnr, frmUpdateDetails.txtSimnr.Font, Brushes.Black, 100, 120);
这篇关于使用PrintDcument和PrintDialog从文本框中打印数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文