Visible Property
Specifies whether an object is visible or hidden. Available at design time and run time.
Object.Visible[ = lExpr]
Property Values
- lExpr
The settings for the Visible property are:Setting Description True (.T.) The default in the Form Designer. The object is visible. False (.F.) The default in program code. The object is hidden.
Remarks
Setting the Visible property for the _SCREEN system variable in versions of Visual FoxPro for Windows prior to version 5 has no effect.
Even if the object is hidden, it can still be accessed in code.
To hide an object at startup, set the Visible property to false (.F.) at design time. If you set the Visible property in code, you can hide an object and display it at run time in response to a particular event.
When a form's Visible property is set to false (.F.), the form is hidden and the last-active form set, form, or other object becomes active. When a form's Visible property is set to true (.T.), the form becomes visible. Setting a form's Visible property to true (.T.) does not affect the form's Order property setting. The form does not become active when Visible is set to true (.T.). Use the Show method to activate a form and make it visible in the same step.
Note If the Visible property of a form is set to false (.F.), the form isn't displayed, even if the form set's Visible property is set to true (.T.). However, if the form set's Visible property is set to false (.F.), all forms contained in the form set are invisible.
Example
The following example demonstrates how the Visible property is used to display controls after they have been added to a form with the AddObject method.
The AddObject method is used to add a Line control and three command buttons to the form. The Visible property is set to true (.T.) for the Line control and the command buttons, displaying them on the form. The Visible property is also used to hide the Line control before its slant direction is changed, and to display the Line control after its slant direction is changed.
frmMyForm = CREATEOBJECT('Form') && Create a form
frmMyForm.Closable = .F. && Disable the window pop-up menu
frmMyForm.AddObject('shpLine','Line') && Add a Line control to the form
frmMyForm.AddObject('cmdCmndBtn1','cmdMyCmndBtn1') && Up Cmnd button
frmMyForm.AddObject('cmdCmndBtn2','cmdMyCmndBtn2') && Down Cmnd button
frmMyForm.AddObject('cmdCmndBtn3','cmdMyCmndBtn3') && Quit Cmnd button
frmMyForm.shpLine.Visible = .T. && Make Line control visible
frmMyForm.shpLine.Top = 20 && Specify Line control row
frmMyForm.shpLine.Left = 125 && Specify Line control column
frmMyForm.cmdCmndBtn1.Visible =.T. && Up Command button visible
frmMyForm.cmdCmndBtn2.Visible =.T. && Down" Command button visible
frmMyForm.cmdCmndBtn3.Visible =.T. && Quit Command button visible
frmMyForm.SHOW && Display the form
READ EVENTS && Start event processing
DEFINE CLASS cmdMyCmndBtn1 AS COMMANDBUTTON && Create Command button
Caption = 'Slant \<Up' && Caption on the Command button
Left = 50 && Command button column
Top = 100 && Command button row
Height = 25 && Command button height
PROCEDURE Click
ThisForm.shpLine.Visible = .F. && Hide the Line control
ThisForm.shpLine.LineSlant ='/' && Slant up
ThisForm.shpLine.Visible = .T. && Show the Line control
ENDDEFINE
DEFINE CLASS cmdMyCmndBtn2 AS CommandButton && Create Command button
Caption = 'Slant \<Down' && Caption on the Command button
Left = 200 && Command button column
Top = 100 && Command button row
Height = 25 && Command button height
PROCEDURE Click
ThisForm.shpLine.Visible = .F. && Hide the Line control
ThisForm.shpLine.LineSlant ='\' && Slant down
ThisForm.shpLine.Visible = .T. && Show the Line control
ENDDEFINE
DEFINE CLASS cmdMyCmndBtn3 AS CommandButton && Create Command button
Caption = '\<Quit' && Caption on the Command button
Cancel = .T. && Default Cancel Command button (Esc)
Left = 125 && Command button column
Top = 150 && Command button row
Height = 25 && Command button height
PROCEDURE Click
CLEAR EVENTS && Stop event processing, close form
ENDDEFINE
See Also
Applies To: CheckBox | Column | ComboBox | CommandButton | CommandGroup | Container Object | Control Object | EditBox | Form | FormSet | Grid | Image | Label | Line | ListBox | OLE Bound Control | OLE Container Control | OptionButton | OptionGroup | PageFrame | Project Object | _SCREEN | Shape | Spinner | TextBox | ToolBar