Programming Guide : Creating Dynamic Frames : How You Can Remove Fields Dynamically : How You Can Restore a Field to Display
 
Share this page          
How You Can Restore a Field to Display
After you set an object's parent to null, the object still exists. The object's attributes (such as size and location) are unchanged. You can, therefore, restore the object to the form simply by giving it a parent. Both of the following statements put the myfield field back onto the current form:
field(myfield).ParentField = CurFrame.TopForm;
frmfield.ParentField = CurFrame.TopForm;
If you want to place the field in a new location or change any other attributes, you can do this either before or after giving it a parent.
When you set attributes of a dynamically created field, OpenROAD might set other attributes implicitly based on the values you set. For example, OpenROAD uses the point size specified for a field's TypeSize and the length of the string provided as its TextValue to set the Width attribute of the field. To perform calculations based on implicitly set attributes, first attach the field to a parent.
For example, assume you want to determine the width of a dynamic field to center it horizontally in the window. You must parent the field before you attempt to center it. The trimfield.ParentField = CurFrame.TopForm statement in the following example attaches the field to the form before the statement below it, which centers the field on the form:
trimfield = FreeTrim.Create();
trimfield.TypeSize = 14;
trimfield.TextValue = 'Frame Title';
trimfield.ParentField = CurFrame.TopForm;
trimfield.AbsXLeft = (CurFrame.WindowWidth -
    trimfield.Width) / 2;
If the parenting statement had followed the statement that centers the new field based on its width, the field would not be positioned correctly.