My AdvTreeView has 2 columns, column 0 is the normal treeview structure, and column 1 contains data. I want to AutoSize the first column and then stretch column 1 to fit, but I cant see how to acheive this.
If I set ColumnsAppearance.Stretch:=FALSE, then call AutoSizeColumn(0) this sizes the column correctly. However, as soon as I set ColumnsAppearance back to TRUE, the width reverts back to 100.
How can I determine the column width computed by the AutoSizeColumn [Columns[0].Width is still 100] and can I manually set the non-stretched column width when Stretch is TRUE.
Hi,
Simultaneously stretching and autosizing is not supported.
You will need to turn off stretching and calculate the auto-sized column and then programmatically set the width of the column. Afterwards stretching can be turned on again, keeping in mind that the StretchColumn is set to 1 and the StretchAll property is set to False. Please note that Auto-sizing is only calculated on the visible nodes.
var
w: Double;
begin
AdvTreeView1.BeginUpdate;
AdvTreeView1.ColumnsAppearance.Stretch := False;
AdvTreeView1.ColumnsAppearance.StretchAll := False;
AdvTreeView1.ColumnsAppearance.StretchColumn := 1;
AdvTreeView1.AutoSizeColumn(0);
w := TAdvTreeViewProtected(AdvTreeView1).ColumnWidths[0];
AdvTreeView1.Columns[0].Width := w;
AdvTreeView1.ColumnsAppearance.Stretch := True;
AdvTreeView1.EndUpdate;
to gain access to the column widths protected property, declare a protected class TAdvTreeViewProtected:
type
TAdvTreeViewProtected = class(TAdvTreeView);
Kind Regards,
Pieter
Pieter Scheldeman2016-01-14 15:46:23