Hi, Hannu -
I suggest you edit the source of a DataWindow that uses a SELECT statement as its data source, and closely examine the source syntax.
Near the top, after some overall properties are defined, are the band properties, followed by the table/column definitions. These are defined in the order that the values are expected to be obtained from the data source (a SELECT statement or a stored procedure).
Included in the table/column definition section comes the retrieve definiton (the PBSELECT or SELECT statement (or stored procedure call).
Next are the various DWObjects (column objects, text objects, lines, etc.) that make up the visual presentation in the order in which they are drawn/rendered. Each column object definition references an ID, which identifies which column definition is associated (1 = the first column definition, 2 = the second, etc.) with each column object.
To be able to successfully change the order of the columns returned by the SELECT statement, all of the following would need to be changed:
1. The SELECT statement.
2. The ordering of the list of column definitions.
3. The ID's referenced by the column objects.
This is what the DataWindow Painter does for you. There is (currently) no programmatic way to dynamically alter this, other than by creating/supplying new syntax for the entire DataWindow. This can be and is done. Of course, you could develop this functionality on your own, essentially duplicating the syntax-creation portion of what the DW Painter does.
Best regards, John