Creating TreeView in Code

Satyapriyanayak
Posted by Satyapriyanayak under VB.NET category on | Points: 40 | Views : 863
Public Class Form1
Inherits System.Windows.Forms.Form

Private Sub btnclick_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclick.Click

TreeView1.Nodes.Add("Student")
TreeView1.Nodes(0).Nodes.Add("Raj")
TreeView1.Nodes(0).Nodes.Add("Ravi")
TreeView1.Nodes(0).Nodes.Add("Rahul")

TreeView1.Nodes.Add("Employee")
TreeView1.Nodes(1).Nodes.Add("Sagar")
TreeView1.Nodes(1).Nodes.Add("Adarsh")
TreeView1.Nodes(1).Nodes.Add("Gautam")

TreeView1.Nodes.Add("SalesMan")
TreeView1.Nodes(2).Nodes.Add("Gitesh")
TreeView1.Nodes(2).Nodes.Add("Suresh")
TreeView1.Nodes(2).Nodes.Add("Ramesh")

End Sub

Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

TextBox1.Text = TreeView1.SelectedNode.Text

End Sub

End Class

Comments or Responses

Login to post response