DBAdvGrid version 2.3.6.27
Code sections:
implementation
{$R *.dfm}
var s : string;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
...
Ini.WriteString('Grid','Settings',DBAdvGrid1.ColumnStatesToString);
...
end;
procedure TForm1.FormShow(Sender: TObject);
...
s := Ini.ReadString('Grid','Settings','');
...
DBAdvGrid1.SetColumnOrder;
end;
procedure TForm1.RunNowBtnClick(Sender: TObject);
...
DBAdvGrid1.ResetColumnOrder;
DBAdvGrid1.Clear; // in case the user has run a request before, clear the results out
...
try
ADOConnection1.Connected := true;
except
raise Exception.Create('Unable to connect to server!');
end;
ADOQuery1.Open;
if s<>'' then
DBAdvGrid1.StringToColumnStates(s);
end;
end;
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:
[Grid]
Settings=2#70,70#0,1#1,1
I expected it to be:
[Grid]
Settings=16#70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70#0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15#1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
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.