Results 1 to 4 of 4

Thread: How to get treeview node child count

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    95

    How to get treeview node child count

    TreeView1.Nodes.Count

    that gets all the nodes count, trying to get just the child node count for a particular parent node, preferably without looping through but whatever.

    TreeView1.Nodes(0).Nodes.Count

    doesn't work, the ending isn't supported, using vb6 and the latest version of treeview(sp6).

  2. #2
    Junior Member Pascal.Scholtes's Avatar
    Join Date
    Jun 2005
    Location
    Saarbrücken / Germany
    Posts
    26

    Re: How to get treeview node child count

    objTreeView.Children Code:
    1. objTreeView.Children

    returns the number of childnodes.
    Look busy. Jesus is coming.

  3. #3
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: How to get treeview node child count

    Try:

    TreeView1.Nodes(0).Children.Count

    Just as described in the manual.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2010
    Posts
    95

    Re: How to get treeview node child count

    I just want everyone to know this stupid control is extremely dangerous the follow code locked up my system, it rebooted, then blue screened on load. DO NOT RUN THIS

    Private Function FindStartEnd(TreeView As TreeView, iStart As Long) As Long
    Dim total As Long
    Dim i As Long
    total = TreeView.Nodes.Count - iStart

    For i = iStart To total
    If TreeView.Nodes(i).Parent Is Nothing Then
    FindSubStartEnd = i
    Exit For
    End If
    Next i
    End Function
    the point of this code is to find the last child node entry for a parent node group since I won't know where the parent nodes are anyway without looping. The problem is I called it with iStart set as 0 and thats when all the crazyness went down, was running inside the ide too.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width