- Version
- Download 73
- File Size 105.17 KB
- File Count 1
- Create Date March 8, 2016
- Last Updated March 8, 2016
Treeview Control in Visual Basic .Net
Treeview Control in Visual Basic .Net
A tree-view control is a window that displays a hierarchical list of items, such as the headings in a document, the entries in an index, or the files and directories on a disk.
In this program, you are allowed to create a node under a root node, user can also select a node and that selected node will then appear in a message box.
Source code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TreeView1.Nodes.Add("Programming", "Programming")
TreeView1.Nodes("Programming").Nodes.Add("Visual Basic.net")
TreeView1.Nodes("Programming").Nodes.Add("C#")
TreeView1.Nodes("Programming").Nodes.Add("Java")
TreeView1.Nodes.Add("Database", "Database")
TreeView1.Nodes("Database").Nodes.Add("MS Access")
TreeView1.Nodes("Database").Nodes.Add("MySQL")
TreeView1.Nodes("Database").Nodes.Add("SQL Server")
TreeView1.Nodes.Add("SearchEngine", "Search Engine")
TreeView1.Nodes("SearchEngine").Nodes.Add("Google")
TreeView1.Nodes("SearchEngine").Nodes.Add("Bing")
TreeView1.Nodes("SearchEngine").Nodes.Add("Ask")
TreeView1.Nodes.Add("Websites", "Websites")
TreeView1.Nodes("Websites").Nodes.Add("webgeekresources.com")
TreeView1.Nodes("Websites").Nodes.Add("inettutor.com")
End Sub
Private Sub TreeView1_NodeMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
MessageBox.Show("Selected Node: " + TreeView1.SelectedNode.Text)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or ComboBox1.Text = "" Then
MessageBox.Show("please enter details")
Else
TreeView1.Nodes(ComboBox1.Text).Nodes.Add(TextBox1.Text)
MessageBox.Show("node added")
End If
End Sub
End Class