function TreeNodeChildCount(mTreeNode: TTreeNode): Integer;
var
I: Integer;
begin
Result := 0;
if not Assigned(mTreeNode) then Exit;
Result := mTreeNode.Count;
for I := 0 to mTreeNode.Count - 1 do
Result := Result + TreeNodeChildCount(mTreeNode[I]);
end; { TreeNodeChildCount }procedure TForm1.TreeView1GetSelectedIndex(Sender: TObject;
Node: TTreeNode);
begin
Caption := IntToStr(TreeNodeChildCount(TTreeView(Sender).Selected));
end;
var
I: Integer;
begin
Result := 0;
if not Assigned(mTreeNode) then Exit;
Result := mTreeNode.Count;
for I := 0 to mTreeNode.Count - 1 do
Result := Result + TreeNodeChildCount(mTreeNode[I]);
end; { TreeNodeChildCount }procedure TForm1.TreeView1GetSelectedIndex(Sender: TObject;
Node: TTreeNode);
begin
Caption := IntToStr(TreeNodeChildCount(TTreeView(Sender).Selected));
end;
TreeView1.Nodes.Item(1).LastNode.GetNodeCount GetNodeCount方法就可以吗?
treeview1.Selected.Count