如何将控件的外观转换为图像? [英] How can I convert a Control's appearance to an image?

查看:34
本文介绍了如何将控件的外观转换为图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户能够在显示它时拖动 Control .我似乎找不到一种将其外观转换为图像的方法(为了将该图像转换为图标以便将其作为拖动图标).

I want a user to be able to drag a Control while showing it. I can't seem to find a way to convert its appearance to an image (in order to convert that image into an icon in order to have that as the dragging icon).

推荐答案

如果我理解正确,您想将控件绘制到图像上吗?使用 Control.DrawToBitmap :

If I understand correctly, you want to draw the control to an image? Use Control.DrawToBitmap:

Bitmap b = new Bitmap(myControl.Width, myControl.Height);
myControl.DrawToBitmap(b, new Rectangle(0, 0, b.Width, b.Height));

这篇关于如何将控件的外观转换为图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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