A TreeView control of Visual basic is used to Display hierarical data in a tree format.this control is Helpful to represent the organization structure, file system or any other system in which you need hierarchical representation.this control is similar to windows explorer which shows a TreeView in left side to show all folder on the hard disk.In TreeView Control You can add nodes and sub nodes.this control provides you the option to add the nodes at design time as well as at runtime.you generally add the nodes at runtime.you can expand and collpase these nodes by clicking on them.the default Event of the TreeView Control is AfterSelect Event.
Properties of TreeView Control:-
Private Sub Form1_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load With TreeView1 .BeginUpdate() .Nodes.Add("Node0") .Nodes(0).Nodes.Add("Node1") .Nodes(0).Nodes.Add("Node2") .Nodes.Add("Node3") .Nodes(1).Nodes.Add("Node4") .Nodes(1).Nodes.Add("Node5") .Nodes.Add("Node6") .Nodes(2).Nodes.Add("Node7") .EndUpdate() End With End Sub
Private Sub TreeView1_AfterSelect(ByVal sender As Object,ByVal e As System.Windows.Forms.TreeViewEventArgs)Handles TreeView1.AfterSelect MessageBox.Show(TreeView1.SelectedNode.FullPath()) End Sub
Now execute the above code.node will be added
Output:-
How to add a node to TreeView Control at runtime in VB.NET
slideToggle() in jQuery