My friend is working in Delphi with VirtualTreeView and has next problem: He has two columns with data and childs for every row in first column. Is that possible not changing first column width to set maximum child column width?

Legend:
How it looks now - look child black reactangle. How it have to be - look red rectangle.
This is called column spanning and yes, it can be done quite easily - just set the TreeOptions -> AutoOptions -> toAutoSpanColumns option to True. The way it works is that if the adjacent column is empty then the caption of the current one is extended into it. As you only want it to work for child columns you have to implement OnGetCellIsEmpty event and return IsEmpty := True only for child nodes, ie something like
procedure TForm1.VT_GetCellIsEmpty(Sender: TBaseVirtualTree;
Node: PVirtualNode; Column: TColumnIndex; var IsEmpty: Boolean);
begin
IsEmpty := (Sender.GetNodeLevel(Node) > 0);
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With