Partager via


REMOVEPROPERTY( ) Function

Removes a property from an object at run time.

REMOVEPROPERTY(oObjectName, cPropertyName)

Parameters

  • oObjectName
    Specifies the name of the object from which to remove the property.
  • cPropertyName
    Specifies the name of the existing property to remove from the object. You can specify only a property name, not an event or method name.

Return Value

Logical data type. REMOVEPROPERTY( ) returns True (.T.) if it successfully removes the property; otherwise, it returns False (.F.).

Remarks

You can use REMOVEPROPERTY( ) to remove properties, but not methods or events. You can use REMOVEPROPERTY( ) with object instances created from Visual FoxPro classes, COM classes, SCATTER...NAME command, _VFP, and _SCREEN.

Properties must be visibly Public, not Hidden or Protected and have been added to an instance of an object, typically using the ADDPROPERTY( ) function, the AddProperty method, or SCATTER...NAME command, so that they can be removed using REMOVEPROPERTY( ).

You cannot remove a property if it is a member of the class definition used to create the instance of the object.

REMOVEPROPERTY( ) function does not remove properties that are specific array elements. To remove an array, provide only the array name.

Examples

Example 1

The following example adds a new property to an object created with the SCATTER command and then removes it.

USE customers
SCATTER NAME oCust
ADDPROPERTY(oCust,"MyProperty")
REMOVEPROPERTY(oCust,"MyProperty")

Example 2

The following example creates a property array for the object, oMyForm, displays its contents, 1 and "Two", and then removes it.

oMyForm = CREATEOBJECT('Form')
ADDPROPERTY(oMyForm, 'MyArray(2)', 1)
oMyForm.MyArray(2) = "Two"
CLEAR
? oMyForm.MyArray(1) 
? oMyForm.MyArray(2)
REMOVEPROPERTY(oMyForm, 'MyArray')
RELEASE oMyForm
CLEAR

See Also

Reference

ADDPROPERTY( ) Function
AddProperty Method

Other Resources

Functions