Solved

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

Posted on 2009-07-02
3
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…

752 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