本文介绍了使用C#Windows应用程序打印表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
海专家
我想打印一个用户填写的实验室帐单"表格,而无需创建报告.我是Windows Apps的新手,(大多熟悉Asp.net).
我的代码如下所示
1)在一个按钮中单击此代码
Hai Experts
I want to print a ''Lab bill" Form that the user has filled out without having to create a report. I am new to Windows Apps, (mostly famliar with Asp.net).
My code is given bellow
1) this code in a button click
ControlPrint mp = new ControlPrint(panel1);
mp.PrintWidth = mp.CalculateSize().Width;
mp.PrintHeight = mp.CalculateSize().Height;
PrintDialog PrintDialog1 = new PrintDialog();
System.Drawing.Printing.PrintDocument docToPrint =
new System.Drawing.Printing.PrintDocument();
PrintDialog1.AllowSomePages = true;
PrintDialog1.ShowHelp = true;
PrintDialog1.Document = docToPrint;
DialogResult result = PrintDialog1.ShowDialog();
if (result == DialogResult.OK)
{
docToPrint.Print();
}
2)
2)
public void StartPrint(Stream streamToPrint, string streamType)
{
this.printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
this.streamToPrint = streamToPrint;
this.streamType = streamType;
System.Windows.Forms.PrintDialog PrintDialog1 = new PrintDialog();
PrintDialog1.AllowSomePages = true;
PrintDialog1.ShowHelp = true;
PrintDialog1.Document = printDocument1;
DialogResult result = PrintDialog1.ShowDialog();
if (result == DialogResult.OK)
{
printDocument1.Print();
}
}
但是我尝试了这个示例,并且只从打印机中取出空白页
我的代码有什么问题,请帮帮我
我提前致谢
but I tried this example and only get a blank page out of the printer
what is the problem in my code and please help me
i give a thanks in advance
推荐答案
这篇关于使用C#Windows应用程序打印表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!