📄 80.txt
字号:
将一个列表中的项拖到另一个列表框
Here注释:s a way that you can let users drag items from one list and drop them in another one. Create two lists (lstDraggedItems, lstDroppedItems) and a text box (txtItem) in a form (frmTip).
Put the following code in the load event of your form.
Private Sub Form_Load()
注释: Set the visible property of txtItem to false
txtItem.Visible = False
注释:Add items to list1 (lstDraggedItems)
lstDraggedItems.AddItem "Apple"
lstDraggedItems.AddItem "Orange"
lstDraggedItems.AddItem "Grape"
lstDraggedItems.AddItem "Banana"
lstDraggedItems.AddItem "Lemon"
注释:
End Sub
In the mouseDown event of the list lstDraggedItems put the following code:
Private Sub lstDraggedItems_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
注释:
txtItem.Text = lstDraggedItems.Text
txtItem.Top = Y + lstDraggedItems.Top
txtItem.Left = X + lstDraggedItems.Left
txtItem.Drag
注释:
End Sub
In the dragDrop event of the list lstDroppedItems put the following code:
Private Sub lstDroppedItems_DragDrop(Source As Control, X As Single, Y As Single)
注释:
If lstDraggedItems.ItemData(lstDraggedItems.ListIndex) = 9 Then
Exit Sub
End If
注释: To make sure that this item will not be selected again
lstDraggedItems.ItemData(lstDraggedItems.ListIndex) = 9
lstDroppedItems.AddItem txtItem.Text
注释:
End Sub
Now you can drag items from lstDraggedItems and drop them in LstDroppedItems.
Note that you cannot drag from the second list to the first. Also, the dragged item remains in the first list. You注释:ll have to address those limitations yourself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -