The visual tree structure of the VirtualStringTree always sticks to the 1st column (the one with index = 0). When you change columns sequence by dragging a column header the tree may look weird (the image below). Is it possible to have the structure be seen always in the first visible column?
The structure is displayed based on the TVirtualStringTree.Header.MainColumn
which needs to be changed every time a column is moved, because moving a column doesn't change its index, but the TVirtualTreeColumn.Position
property. The easiest way is to use OnHeaderDragged
.
procedure HeaderDragged(Sender: TVTHeader; Column: TColumnIndex; OldPosition: Integer);
begin
MyTree.Header.MainColumn := MyTree.Header.Columns.ColumnFromPosition(0);
end;