当用户按下鼠标按钮时 MouseDown 事件发生。
若要在该事件发生时运行宏或事件过程,请将 OnMouseDown 属性设为宏的名称或 [事件过程]。
可以使用 MouseDown 事件来指定当按下或释放特定的鼠标按钮时将发生的操作。与 Click 和 DblClick 事件的不同之处在于:MouseDown 事件使用户能够区分左、中、右的鼠标按钮。也可以为使用 Shift、Ctrl 和 Alt 的鼠标键盘组合键编写代码。
若要使窗体的 MouseDown 事件发生,只需在窗体的空白区域或记录选定器中按下鼠标按钮即可。要使窗体节的 MouseDown 事件发生,只需在窗体节的空白区域中按下鼠标按钮即可。
下列内容适用于 MouseDown 事件:
若要响应由鼠标移动引起的事件,请使用 MouseMove 事件。
下面的示例显示了如何找出引发 MouseDown 事件的鼠标按钮。
若要试用该示例,请将下列事件过程添加到窗体中:
Private Sub Form_MouseDown(Button As Integer, _
Shift As Integer, X As Single, _
Y As Single)
If Button = acLeftButton Then
MsgBox "You pressed the left button."
End If
If Button = acRightButton Then
MsgBox "You pressed the right button."
End If
If Button = acMiddleButton Then
MsgBox "You pressed the middle button."
End If
End Sub