Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SetAll

This is a very cool method. It lets you change the same property of many objects at once. Of course, there are a few rules.

Usage

oContainer.SetAll( cProperty, uValue [, cClass ] )

Parameter

Value

Meaning

cProperty

Character

The property to be changed.

uValue

Expression

The new value.

cClass

Character

Restrict the change only to members of the specified class.

All the container classes have SetAll. Use it to make some change to all the objects contained within the container or, if you want, only to those members that are based on a particular class. For example, you can change the Enabled status of every control on a form or you could change only the command buttons.

SetAll drills down within the container to the very lowest level. For example, calling a grid’s SetAll method affects every control in the grid, as well as the headers and columns (unless you restrict it to a particular class). If the grid contains another grid, the columns, headers and controls in that grid are affected, too.

Note that the object itself is not affected by the SetAll call. That is, if you use SetAll to change the BackColor of controls on a form, the form’s BackColor doesn’t change.

Unfortunately, SetAll isn't as cool as it could be. Although you can specify that all objects of a particular class are changed, you can't specify that all objects that have a particular class somewhere in their class hierarchy or even all objects based on a particular base class should be affected. Since we rarely use objects based on the VFP base classes, and work with an assortment of classes derived from each base class, using SetAll to make a change to all the buttons or all the combos on a form is harder than we'd like.

Check out “Builders and Wizards and Bears, Oh My!” in the “But Wait, There’s More!” section for more on this method.

Example

* Enable all the text boxes on a form from within a method
* of the form
This.SetAll("Enabled",.T.,"TextBox")

See Also

Controls