Table of contents
TOC
折叠目录
展开目录

CheckBox.Click 事件 (访问)CheckBox.Click Event (Access)

office 365 dev account|上次更新日期: 2018/3/13
|
2 参与人员

当用户按下并在一个对象上释放鼠标按钮时, Click事件发生。The Click event occurs when the user presses and then releases a mouse button over an object.

语法Syntax

表达式单击expression. Click

表达式_一个表示复选框对象的变量。_expression A variable that represents a CheckBox object.

注解Remarks

  • 此事件不适用于选项组中的复选框、选项按钮或切换按钮。它仅适用于选项组本身。This event doesn't apply to check boxes, option buttons, or toggle buttons in an option group. It applies only to the option group itself.

  • 此事件适用于包含超链接的控件。This event applies to a control containing a hyperlink.

若要在该事件发生时运行宏或事件过程,请将OnClick属性设置为宏的名称或 [事件过程]。To run a macro or event procedure when this event occurs, set the OnClick property to the name of the macro or to [Event Procedure].

对于控件,用户执行以下操作时发生此事件:For a control, this event occurs when the user:

  • 用鼠标左键单击控件。用右边或中间的鼠标键单击控件不会触发此事件。Clicks a control with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event.

  • 单击包含超链接数据使用鼠标左的按钮控件。用右边或中间的鼠标键单击控件不会触发此事件。当用户将鼠标指针移动包含超链接数据,鼠标指针将变为"手"形图标的控件。当用户单击鼠标键时,超链接将被激活,然后Click事件发生。Clicks a control containing hyperlink data with the left mouse button. Clicking a control with the right or middle mouse button does not trigger this event. When the user moves the mouse pointer over a control containing hyperlink data, the mouse pointer changes to a "hand" icon. When the user clicks the mouse button, the hyperlink is activated, and then the Click event occurs.

  • 通过按箭头键后再按 Enter 键,或通过单击鼠标按钮,在组合框或列表框中选择一项。Selects an item in a combo box or list box, either by pressing the arrow keys and then pressing the ENTER key or by clicking the mouse button.

  • 当命令按钮、复选框、选项按钮或切换按钮具有焦点时按空格键。Presses SPACEBAR when a command button, check box, option button, or toggle button has the focus.

  • 在命令按钮的默认值属性设置为是的窗体上按 ENTER 键。Presses the ENTER key on a form that has a command button whose Default property is set to Yes.

  • 在命令按钮的Cancel属性设置为是的窗体上按 ESC 键。Presses the ESC key on a form that has a command button whose Cancel property is set to Yes.

  • 按下某个控件的访问键。例如,如果某个命令按钮的标题属性设置为&;转,按 ALT + G 会触发该事件。Presses a control's access key. For example, if a command button's Caption property is set to &;Go, pressing ALT+G triggers the event.

通常情况下,将一个Click事件过程或宏附加到命令按钮以执行某些命令和类似命令的操作。其他适用的控件,使用此事件来触发操作以响应本主题前面所述的情况之一。Typically, you attach a Click event procedure or macro to a command button to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to one of the occurrences discussed earlier in this topic.

可以在 DblClick 宏中使用CancelEvent操作取消的第二个Click事件。有关详细信息,请参阅 DblClick 事件主题。You can use a CancelEvent action in a DblClick macro to cancel the second Click event. For more information, see the DblClick event topic.

若要区分的左边、 右边和中间的鼠标按钮,请使用MouseDownMouseUp事件。To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

示例Example

在以下示例中的Click事件过程附加到只读复选框。该事件过程将该窗体的数量文本框中的另一个控件的启用和锁定属性。单击复选框时,事件过程会检查是否是选中还是清除了复选框,然后再设置文本框中的属性,以启用或禁用相应地编辑。In the following example, the Click event procedure is attached to the ReadOnly check box. The event procedure sets the Enabled and Locked properties of another control on the form, the Amount text box. When the check box is clicked, the event procedure checks whether the check box is being selected or cleared and then sets the text box's properties to enable or disable editing accordingly.

若要试用该示例,请向窗体包含一个名为 ReadOnly,并且名为金额文本框的复选框添加下列事件过程。To try the example, add the following event procedure to a form that contains a check box called ReadOnly and a text box named Amount.

Private Sub ReadOnly_Click() 
 With Me!Amount 
 If Me!ReadOnly = True Then ' If checked. 
 .Enabled = False ' Disable editing. 
 .Locked = True 
 Else ' If cleared. 
 .Enabled = True ' Enable editing. 
 .Locked = False 
 End If 
 End With 
End Sub

另请参阅See also

概念Concepts

复选框对象CheckBox Object

© 2018 Microsoft