10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

How You Can Create and Modify Fields Dynamically3. Set field attributes.The following code sets attributes for position and point size:nextquarter.AbsXleft = labelstart;nextquarter.TypeSize = 10;4. Attach the field to the form by giving it a parent. Fields are attached to aform in the following examples:• The following code adds a dynamically created field directly to theform:nextquarter.ParentField = CurFrame.TopForm;• The following code adds a dynamically created field to a compositefield called linechart_subform:linechart_subform = Subform.Create();nextquarter.ParentField =field(linechart_subform);If the parent field is a MatrixField or Stackfield, the field is placed intoa specific cell of the parent with the InsertChild method.The following code creates multiple buttons, getting their label textfrom an array of button names, and inserts the buttons into a stackfield:for i = 1 to name_array.LastRow dobfield = ButtonField.Create();field(bfield).TextLabel = name_array[i];stack_field.InsertChild(fieldtoinsert =bfield, position = i);endfor;After the field has been attached to the form, you can reuse the samereference variable to create another field. If you reuse the reference variable,however, you no longer have a direct way to point to your original field and,therefore, have no simple way to manipulate the field's attributes or data orremove it from the form.If you want to keep reference variables to all fields you create, use an array.For example, the following code declares an array of EntryField objects andcreates each new entry field as a member of this array:efields = Array of EntryField;...j = j + 1;efields[j] = EntryField.Create();The ChildFields attribute of the CompositeField system class stores a referencevariable pointing to each field contained in the composite field. The ChildFieldsattribute often provides the best way to look at all the fields in a composite,although stepping through all the child fields of CurFrame.TopForm looking fora particular field can be awkward.374 <strong>Programming</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!