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.
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.
解决方案 »
- 如何修改内存数据
- 高手帮忙!建立局域网数据库问题
- office 2003 问题
- 关于 当型循环 和 直到型循环 的疑问
- 在写程序中遇到的一个小问题,求解
- 在文本框中写入一个表达式,在另一个文本框中怎样读出它的值?例如?
- 麻烦算法高手出马,求解!!!!!算法完美者,另开贴送500分
- 请问如何用ODBC联接ACCESS数据库?ACCESS数据库可以同时被多少人打开?
- CodeDemon(CWL):请进来拿分!另外还有问题请教!
- 请问哪位师傅能解决在VB下用MCIWnd控件播放VCD时的声道选择问题???
- Bardo(巴顿) xxlroad(土八路) 再请教一个问题
- 一个关于控件和动态连接库注册的问题!
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