5
votes

I use VirtualStringTree (VST) to display data that is grouped, header-details. I need to have an option to allow user to expand, collapse headers to see details and in some cases I need to show data as static view, where they can't expand, collapse, only see full expanded tree:

Here is example when user can expand, collapse node with child node:

enter image description here

And here is example when I want to prevent user to expand/collapse node and always see all expanded (or whatever is shown):

enter image description here

in this test I control by 'Allow Expand/Collapse/ checkbox.

I prevent expand, collapse by adding:

Allowed:=CheckBox1.Checked;

into OnCollapsing/OnExpanding:

procedure TMainForm.VSTCollapsing(Sender: TBaseVirtualTree;
  Node: PVirtualNode; var Allowed: Boolean);
begin
  Allowed:=CheckBox1.Checked;
end;

procedure TMainForm.VSTExpanding(Sender: TBaseVirtualTree;
  Node: PVirtualNode; var Allowed: Boolean);
begin
  Allowed:=CheckBox1.Checked;
end;

I also show/hide TreeLines base on checkbox with

procedure TMainForm.CheckBox1Click(Sender: TObject);
begin
  if CheckBox1.Checked then
    VST.TreeOptions.PaintOptions:=VST.TreeOptions.PaintOptions + [toShowTreeLines]
  else
    VST.TreeOptions.PaintOptions:=VST.TreeOptions.PaintOptions - [toShowTreeLines];
end;

How can I hide this little plus sign when I want to prevent user to expand, collapse node. Any suggestions?


EDIT:

To clear up the confusion with form icon, this is demo project from Virtual Treeivew 5 demo library. The form in IDE has Delphi XE7 icon, when running the project this old icon appear. Don't know why. Just wanted to make sure it is clear that I use XE7 and not any older Delphi versions, where the same solution might not apply.

In IDE the icon if as XE7 icon:

enter image description here

1
On a side-note, your question is tagged Delphi-xe7 yet the icon on your application appears as a very old version of Delphi...? - Jerry Dodge
Didn't notice that at first...it's a demo project from Virtual Treeview 5 demo library, Minimal demo. IDE shows XE7 icon on Form, when running this old one creeps in.. don't know why. - Mike Torrettinni
Must be the old original .res file holding onto it. - Jerry Dodge
I added an image of form icon in IDE, so there will be no confusion that I'm asking about XE7 or older Delphi version - in case the same solution is not for older versions. - Mike Torrettinni

1 Answers

6
votes

The additional option you're looking for is toShowButtons. Use it in the same place you use toShowTreeLines.

The option is documented in VirtualTrees.pas in the declaration for TVTPaintOption:

    toShowButtons,             // Display collapse/expand buttons left to a node.