treeview的用法

haoming0 2003-04-13 11:12:54
如何建立动态树? 谢谢
...全文
69 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
haoming0 2003-04-13
  • 打赏
  • 举报
回复
给解释一下吧?
短歌如风 2003-04-13
  • 打赏
  • 举报
回复
var
Action: TAction;
Category: String;
CatList: TStrings;
CatIndex: Integer;
I: Integer;
Node: TTreeNode;
ParentNode: TTreeNode;
GroupIndex: Integer;
GroupExpanded: Integer;
SeparatorIndex: Integer;
begin
tvActions.Images.Assign(Actions.Images);
GroupIndex := tvActions.Images.Count;
GroupExpanded := GroupIndex + 1;
SeparatorIndex := GroupExpanded + 1;
FExpandedIndex := GroupExpanded;
FCollapsedIndex := GroupIndex;
tvActions.Images.AddImages(imgsAdded);
CatList := TStringList.Create;
try
for I := 1 to Actions.ActionCount - 1 do
begin
try
Action := TAction(Actions.Actions[I]);
Category := Action.Category;
CatIndex := CatList.IndexOf(Category);
if CatIndex < 0 then
begin
ParentNode := tvActions.Items.AddChild(nil, Category);
ParentNode.ImageIndex := GroupIndex;
ParentNode.SelectedIndex := GroupIndex;
Node := tvActions.Items.AddChild(ParentNode, '分隔符');
Node.ImageIndex := SeparatorIndex;
Node.SelectedIndex := SeparatorIndex;
CatIndex := CatList.AddObject(Category, ParentNode);
end;
ParentNode := TTreeNode(CatList.Objects[CatIndex]);
Node := tvActions.Items.AddChild(ParentNode, Action.Caption);
Node.ImageIndex := Action.ImageIndex;
Node.SelectedIndex := Action.ImageIndex;
Node.Data := Action;
except
end;
end;
finally
CatList.Free;
end;

end;

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧