Hirerical Treeview control in VB.NET

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lathamoulali
    New Member
    • May 2008
    • 25

    Hirerical Treeview control in VB.NET

    How to create a hirerical treeview control in VB.NET 2005.Like I want in this way.

    :: GrandParent is GD1
    Parent is : P1
    and Child is C1,C2,C3 and so on.
    Thanks.
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can do it this way :

    Code:
        '''Variable declaration
        Dim gd1 as new Treenode
        Dim p1 as new Treenode
        Dim c1 as new Treenode
        Dim c2 as new Treenode
        Dim c3 as new Treenode
    
    
        '''Define node for grandParent
        gd1.Text = "GrandParent"
       
       '''define node for parent
        p1.Text = "Parent"
    
       '''define child nodes
        c1.Text = "Child1"
        c2.Text = "Child2"
        c3.Text = "Child3"
    
       '''Add child nodes to parent node
          p1.Nodes.Add(c1)
          p1.Nodes.Add(c2)
          p1.Nodes.Add(c3)
    
        ''Add parent node to grandparent node 
        gd1.Nodes.Add(p1)
         
        ''Now, you can add grandparent node to treeview control  
        Treeview1.Nodes.Add("gd1")

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Isn't that what the TreeView object is for?

      Comment

      Working...