Enabled 属性 (Microsoft Forms)Enabled property (Microsoft Forms)

指定控件是否可以接收焦点并响应用户生成的事件。Specifies whether a control can receive the focus and respond to user-generated events.

语法Syntax

对象启用[= Boolean ]object.Enabled [= Boolean ]

Enabled 属性语法包含以下部分:The Enabled property syntax has these parts:

PartPart 说明Description
objectobject 必需。Required. 对象有效。A valid object.
BooleanBoolean 可选。Optional. 对象是否可以响应用户生成的事件。Whether the object can respond to user-generated events.

设置Settings

Boolean 的设置如下:The settings for Boolean are:

Value 说明Description
TrueTrue 控件可接收焦点并响应用户生成的事件,并且控件可通过代码访问(默认)。The control can receive the focus and respond to user-generated events, and is accessible through code (default).
FalseFalse 用户无法使用鼠标、键击、加速键或热键与控件交互。The user cannot interact with the control by using the mouse, keystrokes, accelerators, or hotkeys. 通常,控件仍可通过代码进行访问。The control is generally still accessible through code.

备注Remarks

使用 Enabled 属性来启用和禁用控件。Use the Enabled property to enable and disable controls. 禁用的控件将显示为灰色,而启用的控件不会。A disabled control appears dimmed, while an enabled control does not. 此外,如果控件显示位图,每当控件显示为灰色时位图也会显示为灰色。Also, if a control displays a bitmap, the bitmap is dimmed whenever the control is dimmed. 如果EnabledFalse , 则**** 该控件不会启动事件, 而不会显示为灰色。If Enabled is False for an Image, the control does not initiate events but does not appear dimmed.

EnabledLocked 属性可结合使用以实现如下效果:The Enabled and Locked properties work together to achieve the following effects:

  • 如果 EnabledLocked 都为 True,则控件将可以接收焦点并在窗体中正常显示(不淡显)。If Enabled and Locked are both True, the control can receive focus and appears normally (not dimmed) in the form. 用户可以复制但不能编辑该控件中的数据。The user can copy, but not edit, data in the control.

  • 如果 EnabledTrueLockedFalse,则控件可以接收焦点并在窗体中正常显示。If Enabled is True and Locked is False, the control can receive focus and appears normally in the form. 用户可以复制和编辑控件中的数据。The user can copy and edit data in the control.

  • 如果 EnabledFalseLockedTrue,则控件将不能接收焦点,并且在窗体中淡显。If Enabled is False and Locked is True, the control cannot receive focus and is dimmed in the form. 用户既不能复制也不能编辑控件中的数据。The user can neither copy nor edit data in the control.

  • 如果 EnabledLocked 都为 False,则控件将不能接收焦点,并且在窗体中淡显。If Enabled and Locked are both False, the control cannot receive focus and is dimmed in the form. 用户无法复制或编辑控件中的数据。The user can neither copy nor edit data in the control.

您可以组合 EnabledTabStop 属性的设置以阻止用户通过 Tab 选择某个命令按钮,但仍然允许用户单击该按钮。You can combine the settings of the Enabled and the TabStop properties to prevent the user from selecting a command button with TAB, while still allowing the user to click the button. TabStop 设置为 False 意味着该命令按钮将不会显示在 Tab 键顺序中。Setting TabStop to False means that the command button won't appear in the tab order. 但是, 如果Enabledtrue, 则只要TakeFocusOnClick设置为true, 用户仍可以单击命令按钮。However, if Enabled is True, the user can still click the command button, as long as TakeFocusOnClick is set to True.

当用户将选项卡置于启用的**多页** 或**TabStrip** 中时, 控件中的第一页或选项卡将接收到焦点。When the user tabs into an enabled MultiPage or TabStrip, the first page or tab in the control receives the focus. 如果 MultiPageTabStrip 的第一个页面或选项卡已禁用,则控件的第一个已启用的页面或选项卡将接收焦点。If the first page or tab of a MultiPage or TabStrip is disabled, the first enabled page or tab of that control receives the focus. 如果 MultiPageTabStrip 的所有页面或选项卡均已禁用,则控件将被禁用且无法接收焦点。If all pages or tabs of a MultiPage or TabStrip are disabled, the control is disabled and cannot receive the focus.

如果禁用了某个**框架**, 则它包含的所有控件都将被禁用。If a Frame is disabled, all controls it contains are disabled.

单击禁用的 ListBox 不会发起 Click 事件。Clicking a disabled ListBox does not initiate the Click event.

另请参阅See also

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.