Drag-and-Drop Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

To run this sample

  • Press F5.

Demonstrates

This sample has three examples of drag-and-drop.

  • TextBox   Demonstrates how to prevent a drop on a control. You can drag text from one TextBox control to two others, one of which does not have the AllowDrop property set to True.

  • TreeView   Demonstrates how to move nodes from one TreeView control to another.

  • PictureBox   Demonstrates how to copy images. You can drag images from one PictureBox to another. The AllowDrop property does not appear in the Properties window, and so is set to True in the code.

The data to be dragged should be an instance of the String, Bitmap, or MetaFile class, or an object that implements the ISerializable or IDataObject interface.