Click or drag to resize

RemoveProperty Function

X#
Removes a property from an object at run time.

Namespace:  XSharp.VFP
Assembly:  XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax
 FUNCTION RemoveProperty(
	oObjectName AS Object,
	cPropertyName AS STRING
) AS LOGIC
Request Example View Source

Parameters

oObjectName
Type: Object
Specifies the name of the object from which to remove the property.
cPropertyName
Type: String
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

Type: Logic
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 X# 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. Example 1 The following example adds a new property to an object created with the SCATTER command and then removes it.
X#
1Use customers
2SCATTER NAME oCust
3ADDPROPERTY(oCust,"MyProperty")
4REMOVEPROPERTY(oCust,"MyProperty")
Example 2 The following example creates a property array for the object, codeoMyForm/code, displays its contents, code1/code and code"Two"/code, and then removes it.
X#
1oMyForm = CreateObject('Form')
2ADDPROPERTY(oMyForm, 'MyArray(2)', 1)
3oMyForm.MyArray(2) = "Two"
4Clear
5? oMyForm.MyArray(1)
6? oMyForm.MyArray(2)
7REMOVEPROPERTY(oMyForm, 'MyArray')
8RELEASE oMyForm
9Clear
See Also