I'm Trying to get a VST to resize automatically when its Height and Width is changed. I don't have this problem with other placed VCL components, some of them have a Property "Stretch" like TImage, which lets them adjust automatically. The VST remains stubborn and keeps nodeHeights and Column widths.
I guess I'm just hitting the wrong combinations of settings or something. Any hints would be great, thanks.
From your post I understand that you want to automatically adjust widths of all columns proportionally when the TVirtualStringTree
width changes. If you want that to also happen with the row heights, you can just apply the following correspondingly.
There is no setting for the a propertional column width, but it is simple to achieve in the OnResize
event of the TVirtualStringTree
:
procedure TForm1.VSTResize(Sender: TObject);
begin
VST.Header.Columns[0].Width := MulDiv(VST.Width, 50, 100);
VST.Header.Columns[1].Width := MulDiv(VST.Width, 30, 100);
VST.Header.Columns[2].Width := MulDiv(VST.Width, 20, 100);
end;
In the above, the columns are kept as 50%, 30% and 20% of the components width.