windowsforms-devexpress-dot-utils-dot-dragdrop-dot-dragdropbehaviorproperties.md
Gets or sets whether users are allowed to drop data elements on the attached control.
Namespace : DevExpress.Utils.DragDrop
Assembly : DevExpress.Utils.v25.2.dll
NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core
[DefaultValue(true)]
[DXCategory("DragDrop")]
public bool AllowDrop { get; set; }
<DefaultValue(True)>
<DXCategory("DragDrop")>
Public Property AllowDrop As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | true |
true to allow users to drop data elements on the attached control; otherwise, false.
|
Set the AllowDrag property to false to use the attached control as the target of drag operations only.
To use the attached control as the source only, set the AllowDrop property to false. You can use the DragEnter event’s AllowDrop argument to override this setting for a particular control. You can also use the Cursor event argument to specify the mouse pointer that indicates whether it is allowed to drop items onto the control.
This example shows how to prohibit to drop specific data.
private void dragDropEvents1_DragEnter(object sender, DragEnterEventArgs e) {
List<TreeListNode> list = e.Data as List<TreeListNode>;
// You can prohibit to drop specific data.
if (list.Find((x) => x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) != null) {
e.AllowDrop = false;
e.Cursor = Cursors.No;
e.Handled = true;
}
}
private void dragDropEvents1_DragOver(object sender, DevExpress.Utils.DragDrop.DragOverEventArgs e) {
List<TreeListNode> list = e.Data as List<TreeListNode>;
// You can prohibit to drop specific data.
if (list.Find((x) => x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) != null) {
e.Cursor = Cursors.No;
e.Handled = true;
}
}
Private Sub dragDropEvents1_DragEnter(ByVal sender As Object, ByVal e As DevExpress.Utils.DragDrop.DragEnterEventArgs) _
Handles dragDropEvents1.DragEnter
Dim list As List(Of TreeListNode) = TryCast(e.Data, List(Of TreeListNode))
' You can prohibit to drop specific data.
If list.Find(Function(x) x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) IsNot Nothing Then
e.AllowDrop = false
e.Cursor = Cursors.No
e.Handled = True
End If
End Sub
Private Sub dragDropEvents1_DragOver(ByVal sender As Object, ByVal e As DevExpress.Utils.DragDrop.DragOverEventArgs) _
Handles dragDropEvents1.DragOver
Dim list As List(Of TreeListNode) = TryCast(e.Data, List(Of TreeListNode))
' You can prohibit to drop specific data.
If list.Find(Function(x) x.GetValue(colDEPARTMENT1).ToString().Contains("Finance")) IsNot Nothing Then
e.Cursor = Cursors.No
e.Handled = True
End If
End Sub
Note
Run the XtraTreeList or XtraGrid demo and click Open Solution for more examples.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AllowDrop property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
drag-drop-grid-rows-to-treelist/CS/DragAndDropRows/Form1.cs#L54
behaviorManager1.Attach<DragDropBehavior>(gridView, behavior => {
behavior.Properties.AllowDrop = false;
behavior.Properties.InsertIndicatorVisible = true;
drag-drop-grid-rows-to-treelist/VB/DragAndDropRows/Form1.vb#L53
behaviorManager1.Attach(Of DragDropBehavior)(gridView, Sub(behavior)
behavior.Properties.AllowDrop = False
behavior.Properties.InsertIndicatorVisible = True
See Also
DragDropBehaviorProperties Class