Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

winforms

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

like image 412
ispiro Avatar asked Apr 16 '12 19:04

ispiro


People also ask

How do you display an image in Visual Basic?

Open the Visual Designer of the form containing the control to change. Select the control. In the Properties pane, select the Image or BackgroundImage property of the control. Select the ellipsis ( ) to display the Select Resource dialog box and then select the image you want to display.

How can we display an icon or a bitmap image on the button control?

Steps for assigning bitmap to button in mfc :Create object of bitmap. Load bitmap by using LoadBitmap() Get Handle of button using id and GetDlgItem() method. Modify style so that we can assign bitmap to it.

Which property is using for setting image to image control?

Source Property: We use Source Property to define the image which we want to display. We use source property inside the Image Control to identify the image which we want to display.

How do I add an image to a button in Visual Studio?

create an image. set the source of the image to the right file of your resources (e.g. a . png file that you included to your project) drag the image over the button. A text shows that asks you to press ALT to replace the text of the button with the image.


1 Answers

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));
like image 140
Ry- Avatar answered Sep 16 '22 12:09

Ry-