Solved

Visual Basic Tree View Control - How many branches/nodes can I have???

Posted on 2009-07-02
3
231 Views
Last Modified: 2013-12-26
I have a very basic understanding on how the TreeView control works.  I was wondering if it is possible for a Node of a Node to have a Node? ... and so on.   It seems as if it stops at 2 nodes.  Is this a limitation or is it possible?  If so, how?
0
Comment
Question by:glit
  • 2
3 Comments
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 250 total points
ID: 24770018
hi glit,

         just have a look.

TreeView Control for Visual Basic 6.0 Users:

http://msdn.microsoft.com/en-us/library/ms172635%28VS.80%29.aspx

TreeView Control:

http://www.developerfusion.com/article/77/treeview-control/

TreeView Control:

http://oreilly.com/catalog/vbcnut/chapter/ch05-tv.html



0
 
LVL 22

Assisted Solution

by:danaseaman
danaseaman earned 250 total points
ID: 24776873
Simple example for 5 subnodes:

Option Explicit
 

Private Sub Form_Load()

  Dim root  As Node

  Dim nod   As Node

  Dim i     As Long

  

  Set root = TreeView1.Nodes.Add(, , , "Root")

  Set nod = root

  For i = 1 To 5

     Set nod = TreeView1.Nodes.Add(nod, tvwChild, , "SubNode" & i)

     nod.Expanded = True

  Next

  root.Expanded = True

End Sub

Open in new window

0
 
LVL 22

Expert Comment

by:danaseaman
ID: 24778015
Better example showing usage of Keys and Node objects.

Option Explicit
 

Private Sub Form_Load()

   Dim nod              As Node

   Dim i                As Long

   Dim j                As Long
 

   TreeView1.Nodes.Add , , "Root", "Root"
 

   For i = 1 To 5

      Set nod = TreeView1.Nodes.Add("Root", tvwChild, "Item" & i, "Item" & i)

      For j = 1 To 10

         Set nod = TreeView1.Nodes.Add(nod, tvwChild, , "SubNode" & j)

         nod.Expanded = True

      Next

   Next

   TreeView1.Nodes("Item1").Expanded = True

   TreeView1.Nodes("Root").Expanded = True
 

End Sub

Open in new window

TreeviewSubNodes.png
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now