6. Creating and Using Basic Fields : Common Field Properties : Gravity
 
Share this page                  
Gravity
Because gravity is an attribute of the FormField class, every field has an alignment, or gravity, attribute. However, the gravity attribute is applicable only if a field's immediate parent is a matrix field, a stack field, or a subform.
Because a column field is a stack field, gravity also applies if a field's parent is a column field. Moreover, the form itself is a frame form; and because a frame form is a subform, gravity applies to a field whose parent is the form.
The gravity attribute is not particularly useful when a field's parent is the form itself. (The exception is FA_TOPLEFT.) For example, if you place a button field on a frame and set gravity to FA_CENTER, you “lose” the field because it will be centered in the 24-inch by 24-inch form. Consequently, you are forced to scroll the frame to locate the field. Gravity is quite useful, however, when a field's parent is a matrix field, a stack field, or a subform (other than the form itself).
The ChildGravity attribute is even much more useful than the Gravity attribute. Because gravity applies only when the immediate parent is a matrix field, a subform, or a stack field, only matrix fields, subforms, and stack fields (and their subclasses) have the ChildGravity attribute. For more information, see Matrix Field Properties.
Note:  For more information about the FormField class and using the gravity attribute, see the Language Reference Guide and the Programming Guide.