I want to expand tree on main form when application starts. How i can do it? I cant find corresponding property. C++ builder 2009.
当应用程序启动时,我想在主窗体上展开tree。我怎么做呢?我找不到相应的性质。c++ builder 2009。
3 个解决方案
#2
1
When adding treenode make its expanded property to true
当添加treenode时,使其扩展属性为true
you will find a property for the treeNode Object, set it yo true before add to list of nodes.
您将为treeNode对象找到一个属性,在添加到节点列表之前将其设置为yo true。
and also you can find a method for the treeView called ExpandAll
你还可以找到一个名为ExpandAll的treeView的方法。
My Regards
我的问候
try this code
试试这个代码
//this will expand all nodes of Level and their parents
procedure ExpandTree(Tree: TTreeView; Level: integer);
procedure ExpandParents(Node: TTreeNode);
var
aNode : TTreeNode;
begin
aNode := Node.Parent;
while aNode <> nil do begin
if not aNode.Expanded then
aNode.Expand(false);
aNode := aNode.Parent;
end;
end;
var
aNode : TTreeNode;
begin
if Tree.Items.Count > 0 then begin
aNode := Tree.Items[0];
while aNode <> nil do begin
if aNode.Level = Level then begin
aNode.Expand(false);
ExpandParents(aNode);
end;
aNode := aNode.GetNext;
end;
end;
end;
//this will expand the Node and it's parents
procedure ExpandNode(Node: TTreeNode);
var
aNode : TTreeNode;
begin
Node.Expand(false);
aNode := Node.Parent;
while aNode <> nil do begin
if not aNode.Expanded then
aNode.Expand(false);
aNode := aNode.Parent;
end;
end;
and see the reference http://www.delphipages.com/forum/showthread.php?t=159148
参见参考http://www.delphipages.com/forum/showthread.php?
My Regards
我的问候
#3
0
There a number of Ways of doing this. The easiest would be
有很多方法可以做到这一点。最简单的是
TreeView1.FullExpand;
as in the accepted answer - Alternatively
就像在接受的答案中一样。
if TreeView1.items.GetFirstNode <> nil then
TreeView1.items.GetFirstNode.Expand(True);
or
或
if TreeView1.items[0] <> nil then
TreeView1.items[0].Expand(True);
The Expand method on a TTreeNode is useful if you want to fully expand from a particular node that is not the root node.
如果您想要从不是根节点的特定节点完全展开,那么对于TTreeNode的扩展方法是有用的。
#1
#2
1
When adding treenode make its expanded property to true
当添加treenode时,使其扩展属性为true
you will find a property for the treeNode Object, set it yo true before add to list of nodes.
您将为treeNode对象找到一个属性,在添加到节点列表之前将其设置为yo true。
and also you can find a method for the treeView called ExpandAll
你还可以找到一个名为ExpandAll的treeView的方法。
My Regards
我的问候
try this code
试试这个代码
//this will expand all nodes of Level and their parents
procedure ExpandTree(Tree: TTreeView; Level: integer);
procedure ExpandParents(Node: TTreeNode);
var
aNode : TTreeNode;
begin
aNode := Node.Parent;
while aNode <> nil do begin
if not aNode.Expanded then
aNode.Expand(false);
aNode := aNode.Parent;
end;
end;
var
aNode : TTreeNode;
begin
if Tree.Items.Count > 0 then begin
aNode := Tree.Items[0];
while aNode <> nil do begin
if aNode.Level = Level then begin
aNode.Expand(false);
ExpandParents(aNode);
end;
aNode := aNode.GetNext;
end;
end;
end;
//this will expand the Node and it's parents
procedure ExpandNode(Node: TTreeNode);
var
aNode : TTreeNode;
begin
Node.Expand(false);
aNode := Node.Parent;
while aNode <> nil do begin
if not aNode.Expanded then
aNode.Expand(false);
aNode := aNode.Parent;
end;
end;
and see the reference http://www.delphipages.com/forum/showthread.php?t=159148
参见参考http://www.delphipages.com/forum/showthread.php?
My Regards
我的问候
#3
0
There a number of Ways of doing this. The easiest would be
有很多方法可以做到这一点。最简单的是
TreeView1.FullExpand;
as in the accepted answer - Alternatively
就像在接受的答案中一样。
if TreeView1.items.GetFirstNode <> nil then
TreeView1.items.GetFirstNode.Expand(True);
or
或
if TreeView1.items[0] <> nil then
TreeView1.items[0].Expand(True);
The Expand method on a TTreeNode is useful if you want to fully expand from a particular node that is not the root node.
如果您想要从不是根节点的特定节点完全展开,那么对于TTreeNode的扩展方法是有用的。