HeaderPane
Main
Hide
Share Link
Print

DropTarget Property, SftTree Class

Defines the object (item or cell) that is the current drop target during a drag & drop operation.

Class: SftTree
Namespace: Softelvdm.SftTreeNET
Assembly: Softelvdm.SftTreeNET

Syntax

public object DropTarget { get; set; }
Public Property DropTarget As Object

Value

The drop target object or null/Nothing if there is no drop target

The default value is null/Nothing.

Comments

Defines the object (item or cell) that is the current drop target during a drag & drop operation.

The drop target's appearance is identical to the properties defined for flyby highlighting.

The drop target is usually used while handling DragEnter, DragOver and DragDrop events. A default drop target is provided by the control automatically, but an application can override the drop target while handling these events.

Examples

C#

                return;
            // start dragging the item
            sftTree1.DoDragDrop(e.Item, DragDropEffects.Copy|DragDropEffects.Move);
        }

        private void sftTree1_DragOver(object sender, DragEventArgs e) {
            Debug.WriteLine("sftTree1_DragOver ");
            e.Effect = DragDropEffects.None;
            if (sftTree1.DropTarget != null && e.Data.GetDataPresent(typeof(ItemClass))) {
                // Copy or move based on control key
                if ((Control.ModifierKeys & Keys.Control) != 0)
                    e.Effect = DragDropEffects.Copy;
                else
                    e.Effect = DragDropEffects.Move;
            }
        }

VB.NET

    If item.UsageLocation <> UsageLocationEnum.items Then Return
    ' start dragging the item
    SftTree1.DoDragDrop(e.Item, DragDropEffects.Copy Or DragDropEffects.Move)
End Sub

Private Sub sftTree1_DragOver(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles SftTree1.DragOver
    Debug.WriteLine("sftTree1_DragOver ")
    e.Effect = DragDropEffects.None
    If Not SftTree1.DropTarget Is Nothing And e.Data.GetDataPresent(GetType(ItemClass)) Then
        ' Copy or move based on control key
        If ((Control.ModifierKeys And Keys.Control) <> 0) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.Move
        End If
    End If

See Also SftTree Class | Classes | SftTree/NET 3.0