IControl.DoDragDrop

Syntax

DoDragDrop(

Data: Variant;

AllowedEffects: DragDropEffects;

[Immediate: Boolean = True;]

[Format: DragDropFormat = 0]);

Parameters

Data. Parameter that determines the dragged object.

AllowedEffects. Parameter that determines the view of Drag&Drop effect.

Immediate. Optional parameter that determines when the operation of object Drag&Drop starts. The parameter is set to True by default, the operation of dragging starts immediately. If the parameter is set to False, the operation of dragging starts after the move of the mouse pointer on the determined distance. The distance is determined by the sizes of rectangle centered in the point where the mouse button was pressed. The width and height of rectangle correspond to the system values that are stored in the Windows registry.

Format. Optional parameter that determines, in which format data is transferred when dragging. It is relevant when working with the object navigator. If DragDropFormat.MetabaseObjectList is passed as a parameter value, on passing as the Data parameter the array with object descriptions, this array is treated with the object navigator as a collection of corresponding repository objects, and is handled in a corresponding way (no key pressed - dragging; pressed CTRL - copying; pressed ALT - creating a shortcut).

Description

The DoDragDrop method enables the user to start dragging operation.

Example

Executing the example requires a form and the TreeList component named TreeList1 on it. The AllowDrag property is set to True for the TreeList1 component.

Class TestForm: Form
    TreeList1: TreeList;

    Sub TestFormOnCreate(Sender: Object; Args: IEventArgs);
    Var
        MB: IMetabase;
        MDescs: IMetabaseObjectDescriptors;
        MDesc: IMetabaseObjectDescriptor;
        Nodes: ITreeListNodes;
        Node: ITreeListNode;
        i: Integer;
    Begin
        MB := MetabaseClass.Active;
        MDescs := MB.Root.Children;
        Nodes := TreeList1.Nodes;
        For i := 1 To 10 Do
            MDesc := MDescs.Item(i);
            Node := Nodes.Add(Null, MDesc.Id);
            Node.Data := MDesc;
        End For;
    End Sub TestFormOnCreate;

    Sub TreeList1OnBeginDrag(Sender: Object; Args: IBeginDragEventArgs);
    Var
        Obj: Array Of Variant;
    Begin
        Obj := New Variant[1];
        Obj[0] := TreeList1.Selected.Data;
        TreeList1.DoDragDrop(Obj, DragDropEffects.None, True, DragDropFormat.MetabaseObjectList);
    End Sub TreeList1OnBeginDrag;
End Class TestForm;

When the form is initialized, ten elements are created in the TreeList1 component. The elements correspond to the first ten repository objects. The description of objects is contained in the Data property of elements. When the selected element is dragged, the dragging of appropriate repository object is initialized in the navigator of objects and the navigator processes it in appropriate way.

See also:

IControl