HeaderPane
Main
Hide
Share Link
Print

DoDragDrop Method, SftTree Class

Begins a drag-and-drop operation.

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

Syntax

public new DragDropEffects DoDragDrop(
    object data,
    DragDropEffects allowedEffects );
Public Shadows Function DoDragDrop(
    ByVal data As Object,
    ByVal allowedEffects As DragDropEffects
  ) As DragDropEffects

Parameters

data

The data to drag.

allowedEffects

One of the DragDropEffects values.

Return Value

A value from the DragDropEffects enumeration that represents the final effect that was performed during the drag-and-drop operation.

Comments

Begins a drag-and-drop operation.

DoDragDrop inherits all its functionality from Control.DoDragDrop. Please see DoDragDrop for detailed information.

Examples

C#

            DumpValues(e);
            // get the current item
            if (e.Item == null) return;
            ItemClass item = e.Item;
            // don't drag headers, footers
            if (item.UsageLocation != UsageLocationEnum.items) 
                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

VB.NET

    Debug.Write("sftTree1_DragDetected ")
    DumpValues(e)
    ' get the current item
    If e.Item Is Nothing Then Return
    Dim item As ItemClass = e.Item
    ' don't drag headers, footers
    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

See Also SftTree Class | Classes | SftTree/NET 3.0