转换窗口的形式为图片形式、窗口、图片

2023-09-04 01:25:46 作者:别海南岸

我环顾四周,我可能混淆谷歌的关键字。

I looked around and I may have confused google with the keywords.

我要寻找我的窗口来实现支持模块构成应用中,当用户点击一个按钮,电子邮件发送到支持团队,一个带有附件的截图(有关表格)

I am looking to implement a support module in my windows forms application where when a user clicks on a button, an email is sent to the support team, with an attachment of a screenshot (form in question)

我在寻找类似

form.SaveAsImage(路径)

form.SaveAsImage(path)

在任何想法如何能够实现或我错过了明显

any thoughts on how this can be implemented or have I missed the obvious

.NET 3.5

推荐答案

尝试使用Control.DrawToBitmap方法,并确保该窗体有当您运行code对焦。

Try using the Control.DrawToBitmap method and make sure the form has focus when you run the code.

Graphics gfx = form.CreateGraphics();          
Bitmap bmp = new Bitmap(form.Width, form.Height);
form.DrawToBitmap(bmp, new Rectangle(0, 0, form.Width, form.Height));          
bmp.Save(fileName);