How do I know if a directory entry has no children object?

G

Guest

I'm building a treeview and a list view. I need to know when I reached the
end of the tree nodes, which means that node or directory entry has no
children. Is there a property or method in DirectoryEntry class that does
this? If not, how can I verify this?
 
T

Tom Spink

Pucca said:
I'm building a treeview and a list view. I need to know when I reached
the end of the tree nodes, which means that node or directory entry has no
children. Is there a property or method in DirectoryEntry class that does
this? If not, how can I verify this?

Hi Pucca,

Are you asking about the TreeNode, if it doesn't have any children, or the
DirectoryEntry, if it doesn't have any children?

For the former, simply use the Count property of the Nodes property of the
TreeNode. If the latter, then there's no exposed method to return the
number of children in a DirectoryEntry. If you provide a bit more
information, we may be able to suggest alternatives.

For example, are you recursively building the TreeView?
 
G

Guest

I have a treeview on the left panel and a Listview on the right panel.
Similar to one sees in the Active Driectory computer, users and groups
console.

If user clicks on a node on the left(treeview) then I would expand the node
if there are children and then I list these children nodes in the Listview on
the right.

I'm getting NullRefreneceException when I click on the Users or the Group
node which needs to list all the user and group objects on the listview and
this is where I'm getting the error when testing for the description either
value != null or descriptoin length >0.

if
(child.Properties["description"].Value.ToString() != null)
NodeDetail.Items.Add(new
ListViewItem(new string[] { split[1].ToString(),
child.Properties["description"].Value.ToString() }, 4));
else
NodeDetail.Items.Add("Name",
split[1].ToString(), 4);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top