Drag the records shown in ListView to TreeView

zhaozj2021-02-11  209

Option expedition

Private sub flow_load ()

TreeView1.nodes.add,, "aa", "aa"

TreeView1.nodes.add, "BB", "BB"

Listview1.listitems.add, "cc"

ListView1.listItems.add,, "DD"

ListView1.oledragmode = CCOLEDRAGAUTOMATIC

Listview1.labeledit = lvwmanual

End Sub

Private sub listview1_mousemove (Button as Integer, Shift As Integer, x as single, y as single)

If Button = Vbleftbutton Then

Listview1.dragicon = listview1.selectedItem.createdragimage

Listview1.drag vbbegindrag

END IF

End Sub

Private sub treeview1_dragdrop (Source As Control, X as single, y as single)

IF not TreeView1.drophonghighlight is nothing then

TreeView1.nodes.add TreeView1.drophonghighlight.Key, TVWchild, getNextKey () & listview1.selectedItem.text, listview1.selectedItem.Text

TreeView1.drophonghlight.expanded = true

END IF

End Sub

Private Sub TreeView1_Dragover (Source As Control, X As Single, Y As Single, State As Integer)

Set treeview1.drophighlight = TreeView1.hittest (x, y)

End Sub

Private function getNextKey () AS STRING

DIM SNEWKEY AS STRING

DIM IHOLD AS INTEGER

DIM I as integer

ON Error Goto Myerr

hold = val (TreeView1.nodes (1) .key)

For i = 1 to TreeView1.nodes.count

IF VAL (TreeView1.Nodes (i) .Key> holdim

hold = val (TreeView1.nodes (i) .key)

END IF

NEXT

hold = hood 1

SNEWKEY = CSTR (IHOLD) & "_"

GetnextKey = SNEWKEY

EXIT FUNCTION

Myerr:

GetNextKey = "1_"

END FUNCTION

转载请注明原文地址:https://www.9cbs.com/read-4857.html

New Post(0)