ColumnStatesToString problem

DBAdvGrid version

Code sections:

{$R *.dfm}
var s : string;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

procedure TForm1.FormShow(Sender: TObject);
    s := Ini.ReadString('Grid','Settings','');

procedure TForm1.RunNowBtnClick(Sender: TObject);
  DBAdvGrid1.Clear;  // in case the user has run a request before, clear the results out
      ADOConnection1.Connected := true;
      raise Exception.Create('Unable to connect to server!');
    if s<>'' then

DBAdvGrid is defined with 16 columns, 1 fixed row.  Headers are defined, ADOQuery is "prepared".

On first execution, with no GRID section in the INI file, all 16 columns show up, with multiple rows.  Exit the program.  Run the program again.  When the StringToColumnStates section is executed, the DBGrid reduces to 2 columns!

The value in the INI file shows to be:

I expected it to be:

I have searched the program, and variable S is only used in the code sections above.

I used the AdvStringGrid manual pages 158, 159 to work out persisting the column order, as the user wants to rearrange them.  The options are set for goColMoving and goColSizing in the component, not in code.

I do not understand why the DBGrid is behaving this way.

Anyone have a solution / insight?

Thank you.

Adding this code to the program results in the INI value being saved correctly.  It is only a test to prevent corrupt information from loading.  It is inserted between the INI read and the SetColumnOrder in the OnFormShow event.

  if length(s) > 1 then
    if Copy(s,1,2)<>'16' then
      s := '';

I have no idea as to what the problem is or how it was caused. This does not make sense.

What are your setting for grid.AutoCreateColumns / grid.AutoRemoveColumns?

Can you try to set these to false?

Both were set to true.  The behavior appears to be gone, having upgraded to version of the DBAdvGrid in the March 3, 2015 release.  Setting to false seems to have no apparent effect at this time.

Can you elaborate on the purpose of AutoCreateColumns and AutoRemoveColumns?  I understand the basic words, but want to have an understanding of the intent.  I do not have the luxury of time to read through the source code.  Wish I did. 

From the TDBAdvGrid PDF developers guide:

To get started with TDBAdvGrid, the easiest way is to drop a TDataSource on the form and connect
it to a TDataSet of choice. Activate the dataset and connect the TDataSource to TDBAdvGrid. With
the default setting of TDBAdvGrid.AutoCreateColumns as true, the grid will automatically create
TDBGridColumnItem instances for every DB field in the dataset and add it to the Columns collection.
The TDBGridColumnItem.FieldName will be initialized with the fieldnames found in the dataset
Fields collection. When TDBAdvGrid.AutoRemoveColumns is set to true, deactivating the dataset
will automatically remove all columns from the grid. 

Thanks.  I missed that in the PDF.  Time to get the eyes checked.