我打印的面板基本上是一个注册表单,包含3个小面板,但它只打印一个空白页...我尝试了很多次但没有解决方案。
PrintDialog myPrintDialog = new PrintDialog();
System.Drawing.Bitmap memoryImage = new System.Drawing.Bitmap(panel_stdadmcard.Width, panel_stdadmcard.Height);
panel_stdadmcard.DrawToBitmap(memoryImage, panel_stdadmcard.ClientRectangle);
PrintDocument printDocument1 = new PrintDocument();
if (myPrintDialog.ShowDialog() == DialogResult.OK)
{
System.Drawing.Printing.PrinterSettings values;
values = myPrintDialog.PrinterSettings;
myPrintDialog.Document = printDocument1;
printDocument1.PrintController = new StandardPrintController();
printDocument1.Print();
}
printDocument1.Dispose();
答案 0 :(得分:1)
您将面板绘制为位图,但如果此代码完成,则永远不会使用它。 您应该实现printDocument的PrintPage-Event。 你应该使用DrawImage绘制图像。
答案 1 :(得分:0)
将panel_stdadmcard.ClientRectangle
更改为new Rectangle(0, 0, panel_stdadmcard.Width, panel_stdadmcard.Height)