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

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

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

微信交流群(請用微信掃碼)

        

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

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

在Access窗體視圖中,控件位置都是固定不變的。隻有在佈局視圖或者在設(shè)計視圖的時候纔可以移動控件調(diào)整佈局。

有的時候,程序操作可能被桌麵的某箇頁麵擋住瞭。我們是否可以稍微移動一下控件以緻更好的實(shí)現(xiàn)操作呢?


下麵示例實(shí)現(xiàn)在窗體視圖中以拖曳的方式移動控件,隻需要按住按鈕“按著我拖曳移動”不放,拖動到需要的區(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
    移動訪問