Control.AllowDrop Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets a value indicating whether the control can accept data that the user drags onto it.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

abstract AllowDrop : bool with get, set
override AllowDrop : bool with get, set

Property Value

Type: System.Boolean

true if drag-and-drop operations are allowed in the control; otherwise, false. The default is false.

Notes to Inheritors:

When overriding the AllowDrop property in a derived class, use the base class's AllowDrop property to extend the base implementation. Otherwise, you must provide all the implementation. You are not required to override both the get and setaccessors of the AllowDrop property; you can override only one if needed.

The following code example enables the user to drag an image or image file onto the form, and have it be displayed at the point on it is dropped. The OnPaint method is overridden to repaint the image each time the form is painted; otherwise the image would only persist until the next repainting. The DragEnter event-handling method determines the type of data being dragged into the form and provides the appropriate feedback. The DragDrop event-handling method displays the image on the form, if an Image can be created from the data. Because the DragEventArgs.X and DragEventArgs.Y values are screen coordinates, the example uses the PointToClient method to convert them to client coordinates.

No code example is currently available or this language may not be supported.


for unrestricted Clipboard access to set this property to true. Associated enumeration: the AllClipboard value of System.Security.Permissions.UIPermissionClipboard

.NET Framework
Available since 1.1
Return to top