VB中控件拖动DragMode 设置了还要设置什么才能拖动的
2个回答
展开全部
还要设置接收被拖动控件的控件的事件
例如以下代码是窗体(form)接收被拖动的checkbox
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Dim ck As CheckBox
Set ck = Source
ck.Left = X
ck.Top = Y
End Sub
例如以下代码是窗体(form)接收被拖动的checkbox
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Dim ck As CheckBox
Set ck = Source
ck.Left = X
ck.Top = Y
End Sub
更多追问追答
追问
不对啊,我记的好象不是这样的 好象也就是一个属性的
追答
那是你记错了
展开全部
Dim oX, oY As Single
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oX = X: oY = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Command1.Left = Command1.Left + X - oX: Command1.Top = Command1.Top + Y - oY
End Sub
'你讲的还是不够详细,不知道这是不是你想要的结果
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oX = X: oY = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Command1.Left = Command1.Left + X - oX: Command1.Top = Command1.Top + Y - oY
End Sub
'你讲的还是不够详细,不知道这是不是你想要的结果
追问
运行时用鼠标选中command1拖动,鼠标松开后command1就移过去了
追答
我这个就是你要的那样子,只不过不需要吧DragMode设置为1,要不不好使
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询