呵呵 JOBSXY 说的道理是对的,我怎么一下子没有想到;写一个函数看看行不行:
要第2个接点:
I := GetChildItemsCount(TreeView1, 2);
function GetChildItemsCount(Tree : TTreeView; Child : Word) : Integer;
var
I, J : Integer;
begin
Result := 0;
if Tree.Items.Count = 0 then exit;
J := 0;
for I := 0 to Tree.Items.Count - 1 do
begin
if Tree.Items.Level = 1 then
if Tree.Items.HasChildren then
begin
Inc(J);
if Child = J then
begin
Result := Tree.Items.Count;
exit;
end;
end;
end;
end;