如何打印使用C#.NET生成的visual studio表单 [英] How can a print a visual studio form generated using C#.NET

查看:90
本文介绍了如何打印使用C#.NET生成的visual studio表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C#.NET打印由Visual Studio生成的表单。我正在尝试使用tabControl。我没有得到任何错误。但是当我打印时,我得到了空白纸。我没有获得tabControl中的内容。我使用的代码如下:



我尝试过:



I am trying to print a Form generated by Visual Studio using C#.NET. I am trying to use tabControl. I don't get any errors. But when I print, I get the blank paper. I don't get the content in the tabControl. The code I am using is below:

What I have tried:

Bitmap memoryImage;
private void CaptureScreen()
        {
            Graphics myGraphics = this.CreateGraphics();
            Size s = tabControlMain.Size;

            memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
            Graphics memoryGraphics = Graphics.FromImage(memoryImage);
     memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
         }

private void printDocumentReal_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            e.Graphics.DrawImage(memoryImage, 0, 0);
        }

        private PrintDocument printDocumentReal = new PrintDocument();
        
        private void printToolStripButton_Click(object sender, EventArgs e)
        {
            CaptureScreen();
            printDocumentReal.Print();
        }

推荐答案

从这里开始:

如何:打印Windows窗体 [ ^ ]

代码:打印表单(Visual C#) [ ^ ]
Start here:
How to: Print a Windows Form[^]
Code: Printing the Form (Visual C#)[^]


附加参考



在C#中打印Windows窗体 [ ^ ]



在c#中打印Windows表单〜C#,C ++,C概念,问题和解决方案 [ ^ ]



PrintDocument Class(System.Drawing.Printing) [ ^ ]
Additional reference

Printing Windows Form in C#[^]

Print Windows form in c# ~ C#, C++,C Concepts, Problems and solutions[^]

PrintDocument Class (System.Drawing.Printing)[^]


这篇关于如何打印使用C#.NET生成的visual studio表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆