Visual Basic: Windows 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.
object.DropHighlight [ = value]
The DropHighlight property syntax has these parts:
|object||An object expression that evaluates to an object in the Applies To list.|
|value||A Node or ListItem object.|
The 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 Sub
Subsequently, 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 Sub
Note 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.