Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VirtualTreeView. How to modify child column width?

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?

task

Legend:

  • Circles are nodes
  • rectangles are text (black rectangles of root nodes are two column)

How it looks now - look child black reactangle. How it have to be - look red rectangle.

like image 279
Artem E Avatar asked Jun 10 '26 13:06

Artem E


1 Answers

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;
like image 58
ain Avatar answered Jun 13 '26 21:06

ain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!