Visual Basic Concepts

Changing the Drag Icon

See Also

When dragging a control, Visual Basic uses a gray outline of the control as the default drag icon. You can substitute other images for the outline by setting the DragIcon property. This property contains a Picture object that corresponds to a graphic image.

The easiest way to set the DragIcon property is to use the Properties window. Select the DragIcon property, and then click the Properties button to select a file containing a graphic image from the Load Icon dialog box.

You can assign icons to the DragIcon property from the Icon Library included with Visual Basic. (The icons are located on Visual Studio CD 1, in the \Common\Graphics\Icons directory.) You can also create your own drag icons with a graphics program.

At run time, you can select a drag icon image by assigning the DragIcon property of one control to the same property of another:

Set Image1.DragIcon = Image2.DragIcon

You can also set the DragIcon property at run time by assigning the Picture property of one control to the DragIcon property of another:

Set Image1.DragIcon = Image3.Picture

Or, you can use the LoadPicture function:

Set Image1.DragIcon = LoadPicture("c:\Program _
files\Microsoft Visual Basic\Icons _
\Computer\Disk04.ico")

For More Information    For information on the Picture property and the LoadPicture function, see "Working with Text and Graphics." Also see "Picture Property" and "LoadPicture Function" in the Language Reference.