CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    142

    count number of nodes

    i want to count to number of nodes under each root node so i m doing so
    Code:
    Dim n As Integer
     For Each RootNode As TreeNode In treeAlbum.Nodes
      n = RootNode.Nodes.Count
      Next
      MessageBox.Show("nodes " & n)
    it is counting number of nodes but not exact,some time it is showing more nodes and some time it is showing less time.
    plz help me
    ------------------------------------------------

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: count number of nodes

    Show more code. Is that a click event?
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Mar 2008
    Posts
    142

    Re: count number of nodes

    it is not click event
    it is after select event of tree view

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: count number of nodes

    You are ASSIGNING the value...NOT accumulating it!

    What is being returned is the number of nodes in the last item scanned.

    You need a recursive (yes I know it can be flattened!) way to count the nodes...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

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

Featured