Here is a way to build a grid datawindow which contains columns corresponding to an unknown number of data elements. You could use this approach in creating a project schedule, inventory location system, baseball box score, or any number of other examples. My example assumes the minimum number of columns to be four.
This create grid event returns a string.
long ll_columns, ll_count, ll_pos
string ls_errors, ls_sql, ls_dw_presentation, ls_dw_syntax, ls_find, ls_name, ls_mod_string
// base presentation information
ls_dw_presentation = "style( type=Grid &
Horizontal_spread = 25 ) &
datawindow( units=1 &
Color= 16777215) &
column( Font.Face='Arial' &
Font.Height=-9 &
Font.Weight=400) &
text( Font.Face='Arial' &
Font.Height=-9 &
Font.Weight=400 &
Border=6)"