Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide expand/collapse button in Virtual Treeview?

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

like image 229
Mike Torrettinni Avatar asked Mar 10 '16 16:03

Mike Torrettinni


1 Answers

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.
like image 93
Rob Kennedy Avatar answered Oct 24 '22 00:10

Rob Kennedy