ispiro
ispiro

Reputation: 27743

How can I convert a Control's appearance to an image?

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).

Upvotes: 15

Views: 13960

Answers (1)

Ry-
Ry-

Reputation: 225281

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));

Upvotes: 37

Related Questions