Drag and Drop within Treeview question 
Author Message
 Drag and Drop within Treeview question

Here's some code I grabbed from somewhere (the help file??) ....

'Treeview name is "TV"

Option Explicit
Dim indrag As Boolean    ' Flag that signals a Drag Drop operation.
Dim nodX As Object        ' Item that is being dragged.

Private Sub TV_DragDrop(Source As Control, x As Single, y As Single)

  If TV.DropHighlight Is Nothing Then
   =20
    Set TV.DropHighlight =3D Nothing
    indrag =3D False
    Exit Sub
 =20
  Else

    If nodX =3D TV.DropHighlight Then Exit Sub
     =20
      dlgPM.Cls
      Print nodX.Text & " dropped on " & TV.DropHighlight.Text
      Set TV.DropHighlight =3D Nothing
      indrag =3D False
 =20
  End If

End Sub

Private Sub TV_DragOver(Source As Control, x As Single, y As Single, =
State As Integer)

If indrag =3D True Then
    'Set DropHighlight to the mouse's coordinates.
    Set TV.DropHighlight =3D TV.HitTest(x, y)
  End If
End Sub

Private Sub TV_MouseMove(Button As Integer, Shift As Integer, x As =
Single, y As Single)

If Button =3D vbLeftButton Then ' Signal a Drag operation.
    indrag =3D True ' Set the flag to true.
    ' Set the drag icon with the CreateDragImage method.
    TV.DragIcon =3D TV.SelectedItem.CreateDragImage
    TV.Drag vbBeginDrag ' Drag operation.
  End If
 =20
End Sub

Private Sub TV_MouseDown(Button As Integer, Shift As Integer, x As =
Single, y As Single)

   If Button =3D 1 Then Set nodX =3D TV.SelectedItem ' Set the item =
being dragged.

End Sub

--=20
Randy Birch, MVP Visual Basic

Moderator, Fidonet Visual Basic Programmer's Conference
VBnet, The Visual Basic Developers Resource Centre
http://www.*-*-*.com/



: Hi folks,
:=20
: I am developing an application that needs to build a treeview
: containing data from a table and needs to enable drag and drop
: operations from one node to another. Can I do this with the treeview
: control shipped with Visual Basic 5 ? Someone told me it might be done
: using OLE Drag and Drop but I can't figure out how.
: Any ideas or should I buy a third-party control that has this feature?
:=20
: Thanks
:=20
:=20
: Wagner Maxsen
:=20
:



Fri, 17 Dec 1999 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Drag & drop action within ListView and Treeview

2. Drag and Drop within treeview

3. Drag & Drop from within a Treeview

4. Drag&Drop within TreeView control.

5. Drag Drop Within TreeView

6. Drag & drop action within ListView and Treeview

7. Drag and Drop within treeview

8. TreeView questions. Drag and Drop

9. A drag and drop treeview question

10. TreeView Drag n Drop don't allow dropping a parent into a child

11. Drag/drop from Explorer TreeView to my VB TreeView

12. Drag/drop from Explorer TreeView to my VB TreeView

 

 
Powered by phpBB® Forum Software