Programming Guide : Creating a Frame at Runtime : Dynamic Statements Considerations : How You Can Populate a FlexibleForm, StackField, or MatrixField Dynamically
 
Share this page          
How You Can Populate a FlexibleForm, StackField, or MatrixField Dynamically
Duplicating or creating several fields and parenting them to a FlexibleForm, StackField, or MatrixField that is currently displayed in a frame can be extremely slow because of the amount of configuration and redrawing that must take place as each new field is created and added to its parent field. To increase the performance of creating several fields in this situation, you should unparent the FlexibleForm, StackField, or MatrixField before creating the additional children and reparent it immediately afterward.
For example, if you have a FlexibleForm (flexform) that you are adding children to in a loop, you can use the following code to dramatically increase the response time of this task:
/* Unparenting the FlexibleForm first will speed
** up the creation of all the children we are
** adding.
*/
field(flexform).ParentField = null;
for x = 1 to 100 do
        fld[x] = EntryField.Create();
        /*
        ** Set additional attributes for
        ** each EntryField here.
        */
        fld[x].ParentField = field(flexform);
endfor;
/* Now we reparent the FlexibleForm to cause it
** to reappear on the form (now it is only
** reconfigured and drawn once, instead of
** every time a child is added).
*/
field(flexform).ParentField = CurFrame.TopForm;