You can add the following types of objects to a form:
-
Controls
-
Containers
-
User-defined classes
-
Sharing Information and Adding OLE
Objects in Visual FoxPro belong in one of two categories, depending on the nature of the class they are based on:
-
Containers can hold other containers or controls. They can act as the parent object for other objects. For example, a form, as a container, is the parent object of a check box on that form.
-
Controls can be placed in containers, but cannot be the parent for other objects. For example, a check box cannot contain any other object.
The Form Designer allows you to design both containers and controls.
Container | Can contain |
---|---|
Column |
Headers, and any objects except form sets, forms, toolbars, timers, and other columns |
Command button group |
Command buttons |
Form set |
Forms, toolbars |
Form |
Page frames, grids, any controls |
Grid |
Columns |
Option button group |
Option buttons |
Page frame |
Pages |
Page |
Grids, any controls |
Collection and Count Properties
All container objects in Visual FoxPro have a count property and a collection property associated with them. The collection property is an array referencing each contained object. The count property is a numeric property indicating the number of contained objects.
The collection and count properties for each container are named according to the type of object that can be contained in the container. The following table lists the containers and the corresponding collection and count properties.
Container | Collection Property | Count Property |
---|---|---|
These properties allow you to use a loop to programmatically manipulate all or specific contained objects. For example, the following lines of code set the BackColor property of columns in a grid to alternating green and red:
В | Copy Code |
---|---|
o = THISFORM.grd1 FOR i = 1 to o.ColumnCount IF i % 2 = 0 && Even-numbered column o.Columns(i).BackColor = RGB(0,255,0) && Green ELSE o.Columns(i).BackColor = RGB(255,0,0) && Red ENDIF ENDFOR |