office交流網(wǎng)--QQ交流群號(hào)及微信交流群

Access培訓(xùn)群:792054000         Excel免費(fèi)交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

微信交流群(請(qǐng)用微信掃碼)

        

在Access中實(shí)現(xiàn)窗體內(nèi)控件拖曳移動(dòng)

2018-01-04 17:13:00
tmtony8
原創(chuàng)
6763

在Access窗體視圖中,控件位置都是固定不變的。只有在布局視圖或者在設(shè)計(jì)視圖的時(shí)候才可以移動(dòng)控件調(diào)整布局。

有的時(shí)候,程序操作可能被桌面的某個(gè)頁(yè)面擋住了。我們是否可以稍微移動(dòng)一下控件以致更好的實(shí)現(xiàn)操作呢?


下面示例實(shí)現(xiàn)在窗體視圖中以拖曳的方式移動(dòng)控件,只需要按住按鈕“按著我拖曳移動(dòng)”不放,拖動(dòng)到需要的區(qū)域即可


詳細(xì)源碼:

Option Compare Database
'作者:在水一方
Private xx As Single
Private yy As Single
Private YD As Boolean

Private Sub Command0_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    xx = X
    yy = Y
    YD = True
End Sub

Private Sub Command0_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If YD = True Then
        a = Command0.Left + (X - xx)
        b = Command0.Top + (Y - yy)
        If a > 0 And a < 10000 And b < 10000 And b > 0 Then
            Command0.Move a, b
        End If
    End If
End Sub

    分享
    文章分類
    聯(lián)系我們
    聯(lián)系人: 王先生
    Email: 18449932@qq.com
    QQ: 18449932
    微博: officecn01
    移動(dòng)訪問