Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

How to iterate through all child nodes along with selected Item.

Total Hit ( 2870)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


This is a very simple Recursion technique to iterate child nodes in treeview control.

Click here to copy the following block
Private Sub VisitAllChildNodes(nParent As Node)
  Dim nChild As Node
  Set nChild = nParent.Child
  Do While Not (nChild Is Nothing)
    List1.AddItem nChild.Text
    VisitAllChildNodes nChild
    Set nChild = nChild.Next
  Loop
  Set nChild = Nothing
End Sub


Sub VisitAll(poNode As Node)
  List1.AddItem poNode.Text
  VisitAllChildNodes poNode
End Sub

Private Sub Command1_Click()
  List1.Clear
  VisitAll TreeView1.SelectedItem
End Sub

Private Sub Form_Load()
  TreeView1.Nodes.Add , , "root", "root"
  TreeView1.Nodes.Add "root", tvwChild, "a1", "a1"

  TreeView1.Nodes.Add "a1", tvwChild, "a1-1", "a1-1"
  TreeView1.Nodes.Add "a1", tvwChild, "a1-2", "a1-2"
  TreeView1.Nodes.Add "a1", tvwChild, "a1-3", "a1-3"


  TreeView1.Nodes.Add "root", tvwChild, "b1", "b1"
  TreeView1.Nodes.Add "b1", tvwChild, "b1-1", "b1-1"
  TreeView1.Nodes.Add "b1", tvwChild, "b1-2", "b1-2"

  TreeView1.Nodes.Add "root", tvwChild, "c1", "c1"
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.