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

Label.DblClick 事件 (访问)Label.DblClick Event (Access)

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

当用户按下并释放鼠标左键两次在系统双击时间限度内的对象时, DblClick事件发生。The DblClick event occurs when the user presses and releases the left mouse button twice over an object within the double-click time limit of the system.

语法Syntax

expression.expression.DblClick(* 取消)DblClick( ** Cancel* )

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

参数Parameters

名称Name必需/可选Required/Optional数据类型Data Type说明Description
CancelCancel必需RequiredIntegerInteger该设置确定是否DblClick事件发生。The setting determines if the DblClick event occurs.将_Cancel_参数设置为True (?1) 取消DblClick事件。Setting the Cancel argument to True (?1) cancels the DblClick event.

注解Remarks

在窗体上,当用户双击空白区域或窗体上的记录选择器,DblClick 事件发生。On a form, the DblClick event occurs when the user double-clicks a blank area or record selector on the form.对于控件,它发生,当用户双击控件或它的标签在窗体视图。For a control, it occurs when the user double-clicks a control or its label in Form view.当用户双击窗体或控件但之前双击结果动作 (例如前, 发生 Microsoft Access 选择文本框中插入点所在的单词) 时, DblClick事件发生。The DblClick event occurs when the user double-clicks the form or control but before the result of the double-click action occurs (for example, before Microsoft Access selects the word that the insertion point is on in a text box).

  • 此事件不适用于选项组中的复选框、选项按钮或切换按钮。它仅适用于选项组本身。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 doesn't apply to a label attached to another control, such as the label for a text box. It applies only to "freestanding" labels. Double-clicking an attached label has the same effect as double-clicking the associated control. The normal events for the control occur, not any events for the attached label.

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

对控件而言,双击的结果取决于控件。例如,双击文本框中某个词将选择整个词。双击包含 OLE 对象的控件将会启动用于创建该对象的应用程序,从而可以对该控件进行编辑。For controls, the result of double-clicking depends on the control. For example, double-clicking a word in a text box selects the entire word. Double-clicking a control containing an OLE object starts the application used to create the object, allowing it to be edited.

DblClick事件不会发生在系统双击时间限度内,如果窗体、 窗体节或控件识别而不是单个DblClick事件两个Click事件。If the DblClick event doesn't occur within the double-click time limit of the system, the form, form section, or control recognizes two Click events instead of a single DblClick event.双击时间限制取决于 Windows 控制面板的鼠标选项的按钮选项卡上的双击速度设置。The double-click time limit depends on the setting under Double-Click Speed on the Buttons tab of the Mouse option of Windows Control Panel.

通过在DblClick事件发生时运行宏或事件过程,可以在双击图标时打开窗口或文档。By running a macro or an event procedure when the DblClick event occurs, you can open a window or document when an icon is double-clicked.

双击某个控件将使单击DblClick事件发生。Double-clicking a control causes both Click and DblClick events to occur.如果该控件没有焦点时双击它, EnterGotFocus事件的控件之前单击DblClick事件发生。If the control doesn't already have the focus when you double-click it, the Enter and GotFocus events for the control occur before the Click and DblClick events.

对于接收鼠标事件的对象,事件将按以下顺序发生:For objects that receive mouse events, the events occur in this order:

在 MouseDownMouseUp单击DblClickMouseDownMouseUpClickDblClick

双击命令按钮时,事件将按以下顺序发生:When you double-click a command button, the following events occur in this order:

在 MouseDownMouseUp单击DblClickMouseUp单击MouseDownMouseUpClickDblClickMouseUpClick

第二次单击可能不起作用 (例如,如果Click宏或事件过程在响应第一个Click事件打开模式对话框)。The second click may have no effect (for example, if the Click macro or event procedure opens a modal dialog box in response to the first Click event).要防止运行第二个Click宏或事件过程,请将CancelEvent操作放在宏中DblClick或使用DblClick事件过程中的_取消_参数。To prevent the second Click macro or event procedure from running, put a CancelEvent action in the DblClick macro or use the Cancel argument in the DblClick event procedure.请注意,通常情况下,不建议双击命令按钮。Note that, generally speaking, double-clicking a command button should be discouraged.

如果双击命令按钮之外的其他任何控件,则不会发生第二个Click事件。If you double-click any other control besides a command button, the second Click event doesn't occur.

示例Example

下面的示例演示如何使用DblClick事件过程打开窗体,其中显示组合框的行来源的表中的记录。The following example shows how you can use a DblClick event procedure to open a form that displays records from the table that is the row source of a combo box.当用户双击订单窗体中的销售人员组合框中时,将显示雇员窗体,显示在组合框中所选员工的记录。When the user double-clicks the Salesperson combo box in an Orders form, the Employees form is displayed, showing the record for the employee selected in the combo box.

若要试用该示例,请包含一个名为雇员 id 的组合框为 Orders 表单中添加下列事件过程。To try the example, add the following event procedure to a form named Orders that contains a combo box named EmployeeID.组合框应作为其行来源具有同一个表的雇员窗体 (或基于该表的查询) 的源。The combo box should have as its row source the same table that is the source for the Employees form (or a query based on that table).

Private Sub EmployeeID_DblClick(Cancel As Integer) 
 DoCmd.OpenForm "Employees", , , _ 
 "EmployeeID = Forms!Orders!EmployeeID" 
End Sub

另请参阅See also

概念Concepts

Label 对象Label Object

© 2018 Microsoft