TreeView 怎样插入下级节点(30分)

  • 主题发起人 主题发起人 dohye
  • 开始时间 开始时间
D

dohye

Unregistered / Unconfirmed
GUEST, unregistred user!
TreeView 怎样插入下级节点和同级节点
 

treeview1.items.addchild

treeview1.Items.add
 
好像不能增加下级节点
 
这是Delphi的例子,你可以参考一下:

procedure TForm1.Button2Click(Sender: TObject);
var
MyTreeNode1, MyTreeNode2: TTreeNode;
begin
with TreeView1.Items do
begin
Clear; { remove any existing nodes }
MyTreeNode1 := Add(nil, 'RootTreeNode1'); { Add a root node }
{ Add a child node to the node just added }
AddChild(MyTreeNode1,'ChildNode1');

{Add another root node}
MyTreeNode2 := Add(MyTreeNode1, 'RootTreeNode2');
{Give MyTreeNode2 to a child }
AddChild(MyTreeNode2,'ChildNode2');

{Change MyTreeNode2 to ChildNode2 }
{ and add a child node to it}
MyTreeNode2 := TreeView1.Items[3];
AddChild(MyTreeNode2,'ChildNode2a');

{Add another child to ChildNode2, after ChildNode2a }
Add(MyTreeNode2,'ChildNode2b');

{add another root node}
Add(MyTreeNode1, 'RootTreeNode3');
end;
end;
 
接受答案了.
 

Similar threads

S
回复
0
查看
835
SUNSTONE的Delphi笔记
S
S
回复
0
查看
765
SUNSTONE的Delphi笔记
S
D
回复
0
查看
767
DelphiTeacher的专栏
D
D
回复
0
查看
802
DelphiTeacher的专栏
D
后退
顶部