1个回答
2017-10-24 · 知道合伙人软件行家
关注
展开全部
BeforeDragOver 事件 当拖放操作正在进行时 触发。
有多种窗体控件支持此事件,参数稍有不同。
以下是此事件的一个示例:
1、建立一个窗体,并放置两个 ListBox 控件(ListBox1 和 ListBox2)。
2、为示例方便,设置了 ListBox1 的 RowSource 属性,添加一些数据:
3、编写代码:
Private Sub ListBox2_BeforeDragOver(ByVal Cancel As _
MSForms.ReturnBoolean, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal DragState As Long, _
ByVal Effect As MSForms.ReturnEffect, _
ByVal Shift As Integer)
Cancel = True
Effect = 1
End Sub
Private Sub ListBox2_BeforeDropOrPaste(ByVal _
Cancel As MSForms.ReturnBoolean, _
ByVal Action As Long, ByVal Data As _
MSForms.DataObject, ByVal X As Single, _
ByVal Y As Single, ByVal Effect As _
MSForms.ReturnEffect, ByVal Shift As Integer)
Cancel = True
Effect = 1
ListBox2.AddItem Data.GetText
End Sub
Private Sub ListBox1_MouseMove(ByVal Button As _
Integer, ByVal Shift As Integer, ByVal X As _
Single, ByVal Y As Single)
Dim MyDataObject As DataObject
If Button = 1 Then
Set MyDataObject = New DataObject
Dim Effect As Integer
MyDataObject.SetText ListBox1.Value
Effect = MyDataObject.StartDrag
End If
End Sub
运行效果如图:
在左边的 ListBox1 某条目上,按下鼠标左键,并拖动到右边的 ListBox2 中:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询