Enabled Property

Purpose

Returns or sets a value that determines whether a form or control can respond to user-generated events.

Syntax

Object.Enabled [ = Boolean ]

Object:Ocx object
Boolean:True or False

Description

The Enabled property allows forms and controls to be enabled or disabled at run time. For example, you can disable objects that don't apply to the current state of the application. You can also disable a control used purely for display purposes, such as a text box that provides read-only information.

The default setting is True, which allows object to respond to events. Setting it to False prevents it from responding to events.

Disabling a Timer control by setting Enabled to False cancels the countdown set up by the control's Interval property.

For a MenuItem object, Enabled is normally read/write at run time.

Example

Form frm1

Ocx TextBox txt1 = "", 10, 10, 100, 14 : .BorderStyle = 1

Ocx Command cmd1 = "Save", 20, 35, 80, 22 : cmd1.Enabled = False

txt1.SetFocus

Do

Sleep

Until Me Is Nothing

 

Sub cmd1_Click

frm1.Close

EndSub

 

Sub txt1_Change ()

If txt1.Text = "" Then   ' See if text box is empty.

cmd1.Enabled = False   ' Disable button.

Else

cmd1.Enabled = True   ' Enable button.

End If

End Sub

See Also

Form, Ocx

{Created by Sjouke Hamstra; Last updated: 04/10/2014 by James Gaite}