大家好,请看以下代码:
procedure TForm1.Button1Click(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;
showmessage('TreeView1.Items[3].Text:' + TreeView1.Items[3].Text);
end;end.
请问在以上程序当中为什么TreeView1.Items[3]会是ChildNode2,而不是RootTreeNode3吗?而且通过跟踪发
TreeView1.Items[1] = childNode1,TreeView1.Items[2]= RootTreeNode,请问这是为什么?
procedure TForm1.Button1Click(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;
showmessage('TreeView1.Items[3].Text:' + TreeView1.Items[3].Text);
end;end.
请问在以上程序当中为什么TreeView1.Items[3]会是ChildNode2,而不是RootTreeNode3吗?而且通过跟踪发
TreeView1.Items[1] = childNode1,TreeView1.Items[2]= RootTreeNode,请问这是为什么?
解决方案 »
- delphi 手动窗体创建函数
- 程序运行就最小化
- list index out of bounds是怎么回事?请大家帮帮忙!!!
- 请问如何获取WebBrowser控件中页面里的所有元素的名称,不是基于表单的元素,是所有元素,有些页面没有表单,导致我无法获取~
- 我这儿有类似速达的表格控件源码,如果有人能帮忙改进的话我就公开源码!(3)
- 我是初學Delphi6。有幾個問题想請教一下各位!
- 一个sql问题
- 问一下几个元件在元件盒的位置,急!
- 很菜的问题:关于var。查HELP只给很少的信息所以只好来问
- 排序
- 论坛自动发帖子相关的几个问题,请高手赐教?
- Delphi 调用API做的完成端口出现 10055错误,请高手指点~~
'RootTreeNode1' 0
'ChildNode1’ 1
'RootTreeNode2' 2
'ChildNode2' 3