KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: How to preformat a dynamically built List Box object
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: May 18, 2012

With all the 4D Language enhancements to the 4D v13 List Box object it is quite easy to create a single 4D Project form with an empty List Box object and build the List Box programmatically for use in many different situations. This is very efficient alternative to constructing a number of different forms each with a single purpose List Boxes.

The process can be streamlined to where the List Box appearance can be completely predefined and only the columns will have to be added and rows populated with data before presentation to the user.

To do this, in the form editor, create the list box and add one column. Define how you want the list box to appear, such as headers, footers, alternate row coloring, etc.

Next, in the object properties, turn on the On Load form event.

Next, edit the object method and during the On Load event, delete the existing column. Code similar to this:

Case of
  : (Form event=On Load)
    C_LONGINT(ListForm_L)
    LISTBOX DELETE COLUMN(ListForm_L;1;LISTBOX Get number of columns(ListForm_L))

End case


Last, execute the code that adds the columns and populate the rows. The list box will appear just as it was defined in the form editor.