Mik*_*nni 5 delphi virtualtreeview delphi-xe7
我使用VirtualStringTree(VST)来显示分组的数据,标题详细信息.我需要有一个选项允许用户展开,折叠标题以查看详细信息,在某些情况下我需要将数据显示为静态视图,在这里他们无法展开,折叠,只能看到完整展开的树:
以下是用户可以展开的示例,使用子节点折叠节点:
这是一个示例,当我想阻止用户展开/折叠节点并始终看到所有展开(或显示的任何内容):
在此测试中,我通过'允许展开/折叠/复选框控制.
我通过添加以下内容来防止展开,折
Allowed:=CheckBox1.Checked;
Run Code Online (Sandbox Code Playgroud)
进入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;
Run Code Online (Sandbox Code Playgroud)
我还基于复选框显示/隐藏TreeLines
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;
Run Code Online (Sandbox Code Playgroud)
当我想阻止用户展开,折叠节点时,如何隐藏这个小加号.有什么建议?
编辑:
为了清除与表单图标的混淆,这是来自Virtual Treeivew 5演示库的演示项目.IDE中的表单具有Delphi XE7图标,在运行项目时会出现这个旧图标.不知道为什么.只是想确保我使用XE7而不是任何旧的Delphi版本,其中相同的解决方案可能不适用.
在IDE中,图标如果为XE7图标:
您正在寻找的附加选项是toShowButtons.在您使用的同一个地方使用它toShowTreeLines.
VirtualTrees.pas中的选项记录在以下声明中TVTPaintOption:
toShowButtons, // Display collapse/expand buttons left to a node.
Run Code Online (Sandbox Code Playgroud)