Search code examples
delphitvirtualstringtree

How to set the node height in Tvirtualstringtree


I have set the the height of the FocusedNode using following code

procedure TMainForm.SetheightClick(Sender: TObject);
begin
  if Assigned(tree1.FocusedNode) then
    Tree1.NodeHeight[Tree1.FocusedNode] := strtointdef(edit8.Text ,50);
end;

I would like to set the height of Tvirtualstringtree in multiselect nodes. How to do it?


Solution

  • There's no way to setup node height for selected nodes in one call, so I guess you're asking just for selected nodes iteration. So to setup height for all selected nodes, you can write e.g.:

    var
      Size: Cardinal;
      Node: PVirtualNode;
    begin
      Size := StrToIntDef(Edit8.Text, 50);
    
      Tree1.BeginUpdate;
      try
        for Node in Tree1.SelectedNodes do
          Tree1.NodeHeight[Node] := Size;
      finally
        Tree1.EndUpdate;
      end;
    end;