尝试使用Control.DrawToBitmap方法,并确保在运行代码时表单具有焦点.
using (Graphics gfx = form.CreateGraphics())
{
using (Bitmap bmp = new Bitmap(form.Width, form.Height, gfx))
{
form.DrawToBitmap(bmp, new Rectangle(0, 0, form.Width, form.Height));
bmp.Save(fileName);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3552 次 |
| 最近记录: |