如何以编程方式获取.Net WinForms控件的屏幕截图? [英] How to get a screen capture of a .Net WinForms control programmatically?

查看:113
本文介绍了如何以编程方式获取.Net WinForms控件的屏幕截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式获取.Net控件的图片?

How do you programmatically obtain a picture of a .Net control?

推荐答案

每个控件都有一个名为 DrawToBitmap 。你不需要p / invoke来执行此操作。

There's a method on every control called DrawToBitmap. You don't need to p/invoke to do this.

Control c = new TextBox();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(c.Width, c.Height);
c.DrawToBitmap(bmp, c.ClientRectangle);

这篇关于如何以编程方式获取.Net WinForms控件的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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