DropHighlight Property (ListView, TreeView Controls)
      Returns or sets a reference to a Node or ListItem object that is highlighted with the system highlight color when the cursor moves over it.Syntaxobject.DropHighlight [ =  value]The DropHighlight property syntax has these parts:Part Description 
object An object expression that evaluates to an object in the Applies To list. 
value A Node or ListItem object. 
ResThe DropHighlight property is typically used in combination with the HitTest method in drag-and-drop operations. As the cursor is dragged over a ListItem or Node object, the HitTest method returns a reference to any object it is dragged over. In turn, the DropHighlight property is set to the hit object, and simultaneously returns a reference to that object. The DropHighlight property then highlights the hit object with the system highlight color. The following code sets the DropHighlight property to the object hit with the HitTest method.Private Sub TreeView1_DragOver _
(Source As Control, X As Single, Y As Single, State As Integer)
   Set TreeView1.DropHighlight = TreeView1.HitTest(X,Y)
End SubSubsequently, you can use the DropHighlight property in the DragDrop event to return a reference to the last object the source control was dropped over, as shown in the following code:Private Sub TreeView1_DragDrop _
(Source As Control, x As Single, y As Single)
   ' DropHighlight returns a reference to object drop occurred over.
   Me.Caption = TreeView1.DropHighlight.Text 
   ' To release the DropHighlight reference, set it to Nothing.
   Set TreeView1.DropHighlight = Nothing
End SubNote that in the preceding example, the DropHighlight property is set to Nothing after the procedure is completed. This must be done to release the highlight effect.

解决方案 »

  1.   

    '在LISTVIEW中拖到一条记录到TREEVIEW中:Private Sub Form_Load()
    TreeView1.OLEDropMode = ccOLEDropManual '接受控件间的拖/放
    ListView1.OLEDragMode = ccOLEDragAutomatic
    For i = 1 To 10
        ListView1.ListItems.Add , , "List" & i
        TreeView1.Nodes.Add , , , "Tree" & i
    Next
    Set ListView1.DragIcon = LoadPicture("C:\WINDOWS\Winupd.ico")
    End SubPrivate Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button <> 1 Then Exit Sub
    ListView1.OLEDrag
    End SubPrivate Sub ListView1_OLEStartDrag(Data As MSComctlLib.DataObject, AllowedEffects As Long)
    Data.SetData ListView1.SelectedItem.Text
    End SubPrivate Sub TreeView1_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
    TreeView1.Nodes.Add , , , Data.GetData(1)
    End Sub