看看这个从一个节点, 转到下面所有的子节点中. Function FindChild(aNode : TTreeNode, aText : string); begin result = nil; aNode.count = 0 then exit; aNode := aNode.GetFirstChild; while (aNode <> nil) do begin if aNode.Text = aText then Begin REsult = aNode; break; end; result := FindChild(aNode, aText); if Result <> nil then break; aNode := aNode.GetNextSibling; end; end;
如现在是TreeView.Items.Item[2]
那下一个节点就应该是 TreeView.Items.Item[3] 了
TreeView.Items.Item[2]和TreeView.Items.Item[3]可能不是同发层的
Function FindChild(aNode : TTreeNode, aText : string);
begin
result = nil;
aNode.count = 0 then exit;
aNode := aNode.GetFirstChild;
while (aNode <> nil) do
begin
if aNode.Text = aText then
Begin
REsult = aNode;
break;
end;
result := FindChild(aNode, aText);
if Result <> nil then break;
aNode := aNode.GetNextSibling;
end;
end;