JavaScript Editor js editor     Web development 

Main Page

The container and the class hierarchy are two separate entities. Objects are referenced in the container hierarchy, whereas Visual FoxPro searches for event code up through the class hierarchy.

To manipulate an object, you need to identify it in relation to the container hierarchy. For example, to manipulate a control on a form in a form set, you need to reference the form set, the form, and then the control.

You can compare the referencing of an object within its container hierarchy to giving Visual FoxPro an address to your object. When you describe the location of a house to someone outside your immediate frame of reference, you need to indicate the country, the state or region, the city, the street, or just the street number of the house, depending on how far they are from you. Otherwise, there could be some confusion.

The following illustration shows a possible container-nesting situation.

FoxProFormSetProperties graphic

To disable the control in the grid column, you need to provide the following address:

В Copy Code
 Grid.Column.Control.Enabled = .F.

The ActiveForm property of the application object (_VFP) allows you to manipulate the active form even if you don't know the name of the form. For example, the following line of code changes the background color of the active form, no matter what form set it belongs to:

В Copy Code
_VFP.ActiveForm.BackColor = RGB(255,255,255)

Similarly, the ActiveControl property allows you to manipulate the active control on the active form. For example, the following expression entered in the Watch window displays the name of the active control on a form as you interactively choose the various controls:

В Copy Code

Relative Referencing

When you are referencing objects from within the container hierarchy (for example, in the Click event of a command button on a form in a form set), you can use some shortcuts to identify the object you want to manipulate. The following table lists properties or keywords that make it easier to reference an object from within the object hierarchy:

Property or keyword Reference


The immediate container of the object.


The object.


The form that contains the object.


The form set that contains the object.

You can use THIS, THISFORM, and THISFORMSET only in method or event code.

The following table provides examples of using THISFORMSET, THISFORM, THIS, and Parent to set object properties:

Command Where to include the command

THISFORMSET.frm1.cmd1.Caption = "OK"

In the event or method code of any controls on any form in the form set.

THISFORM.cmd1.Caption = "OK"

In the event or method code of any control on the same form that cmd1 is on.

THIS.Caption = "OK"

In the event or method code of the control whose caption you want to change.

THIS.Parent.BackColor = RGB(192,0,0)

In the event or method code of a control on a form. The command changes the background color of the form to dark red.

See Also

JavaScript Editor js editor     Web development