C#Windows应用程序中的打印面板 [英] Print panel in C# windows application
本文介绍了C#Windows应用程序中的打印面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C#网络表单中有一个面板,其中包含图像,标签和文本框.我想在单击按钮时打印整个面板.我该怎么做?我对C#Windows应用程序不熟悉.有人请帮助我...
谢谢.
Hi,
I''m having a panel in C# webform which contains images, labels and textboxes. I want to print the whole panel when a button is clicking. How can I do it? I''m not familiar with C# windows application. Anyone please help me...
Thank you.
推荐答案
嗨 您可以使用以下代码:
Hi you can use this code:
private void doc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Panel grd = new Panel();
Bitmap bmp = new Bitmap(grd.Width, grd.Height, grd.CreateGraphics());
grd.DrawToBitmap(bmp, new Rectangle(0, 0, grd.Width, grd.Height));
RectangleF bounds = e.PageSettings.PrintableArea;
float factor = ((float)bmp.Height / (float)bmp.Width);
e.Graphics.DrawImage(bmp, bounds.Left, bounds.Top, bounds.Width, factor * bounds.Width);
}
并制作一个按钮并编写以下代码:
and make a button and write this code:
private void button1_Click_1(object sender, EventArgs e)
{
System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
doc.Print();
}
阿米尔(Amir)
Amir
朋友,
这将对您有很大帮助...
打印面板c#的内容 [ http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23538875.html [ ^ ]
http://www.hotscripts.com/forums/windows- net-programming/46984-solved-printing-c-net.html [ http://social.msdn.microsoft.com/Forums/zh/csharpgeneral/thread/0d83e783-7673-434b-9829-0cc0ba9d8810 [
Hi friend,
This will help you a lot...
print content of panel c#[^]
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_CSharp/Q_23538875.html[^]
http://www.hotscripts.com/forums/windows-net-programming/46984-solved-printing-c-net.html[^]
http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/0d83e783-7673-434b-9829-0cc0ba9d8810[^]
这篇关于C#Windows应用程序中的打印面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文