This is a different problem.
By setting the properties at runtime, it's the same as if some user had interactively changed the properties, those properties are not stored anywhere so, if you close and reopen the query you must redo, recreate or replay the actions that changed the grid properties, in your sample you have to copy the third section of your formshow procedure into a new procedure 'UpdateGrid' for example and call it, then after reopened the dataset call 'UpdateGrid' again. I have not checked your second sample but if the properties are stored at design time, then when you reopen the dataset, the grid already have the changed properties (with respect to a unmodified at design time grid) so it should work OK.
The problem madref reported, as I understood it, is that if you delete one record, then some columns that had 0 width (and as a consequence remained hidden), will suddenly become visible because their widths are no 0 anymore.