I just upgraded from Lazarus 3.4 to 3.8 with the hope that an issue I have will magically disappear, but here I am!
I am working in a separate unit where a class is defined.
The constructor of this class takes a TPageControl as a parameter and caches it.
When a method is called, it enters a parsing pipeline, does some blablabla, and then creates a TStringGrid and places it in the current (or new) TPageControl tab - TTabSheet.
Tab := instance.FPages.Pages[0]; // Uses the default tab
Then it creates a TStringGrid and places it inside:
Grid := TStringGrid.Create(Tab);
Grid.Parent := Tab;
Grid.Align := alClient;
Grid.ScrollBars := ssBoth;
Finally, it adds custom columns in a loop based on a TStringList containing column names:
for columnName in columnNames do
begin
Col := Grid.Columns.Add;
Col.Title.Caption := columnName;
Col.Alignment := taCenter; // nope
//Col.Expanded := true; // nope
end;
So first of all, it does not seem to obey the column's Expanded and Alignment properties (The Alignment works only on editable cells, but not the columns).
And then I really want to fill up the entire available space with the columns, but setting the grid property "AutoFillColumns" to true breaks it completely -
It does not fit all the columns on the window, giving them way too much redundant space and the scrollbar does not even appear, making me really confused as to what is really happening and what am I doing wrong.
ChatGPT did not know what it was talking about, TStringGrid refpages and tutorials do not cover adding columns (at least "expanded") at runtime, google searches were only making references to Delphi and 2-3 not-very-related forum topics, mutating the "SizePriority" and "Width" properties did not fix the problem, AutoSizeColumns and AdjustSize didn't help either.
So I am hoping that this post clarifies things up a little
