如何在C#窗口应用程序中打印Groupbox中的控件? [英] How to print controls in Groupbox, in c# window application?
本文介绍了如何在C#窗口应用程序中打印Groupbox中的控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在C#窗口应用程序中打印Groupbox中的控件?
感谢您的回复
How to print controls in Groupbox, in c# window application?
thanks for your reply
推荐答案
不要。
他们会看起来垃圾:屏幕分辨率是~75dpi,打印机是> 300dpi。
相反,使用PrintDocument class [ ^ ]并正确执行!
Don't.
They will look rubbish: screen resolution is ~ 75dpi, printers are >300dpi.
Instead, use a PrintDocument class[^] and do it properly!
private void btnPrint_Click(object sender, EventArgs e)
{
//PrintDocument pd = new PrintDocument();
//pd.PrintPage += new PrintPageEventHandler(PrintImage);
//pd.Print();
PrintDocument doc = new PrintDocument();
doc.PrintPage += this.Doc_PrintPage;
PrintDialog dlgSettings = new PrintDialog();
dlgSettings.Document = doc;
if (dlgSettings.ShowDialog() == DialogResult.OK)
{
doc.Print();
}
}
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
{
float x = e.MarginBounds.Left;
float y = e.MarginBounds.Top;
Bitmap bmp = new Bitmap(this.groupBoxInvoice.Width, this.groupBoxInvoice.Height);
this.groupBoxInvoice.DrawToBitmap(bmp, new Rectangle(0, 0, this.groupBoxInvoice.Width, this.groupBoxInvoice.Height));
e.Graphics.DrawImage((Image)bmp, x, y);
}
打印Windows窗体没有使用API [ ^ ]是一篇可以帮助你的好文章。
Print Windows Forms w/o using API[^] is a good article that could help you.
这篇关于如何在C#窗口应用程序中打印Groupbox中的控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文