January 27, 2015 05:39 by
Peter
The Windows Forms Tree view in VB.NET control helps to show the hierarchy of nodes that may be wont to represent the organization structure, file system or the other system which incorporates hierarchical illustration. For each node additional within the hierarchy, user will add a child node to it or a sibling node to it provided there's a parent node for the chosen node present.
The article below explores the Tree read management and depicts the method as a way to add a toddler node or a relative node to the chosen node.
1. How to add a toddler node to a particular node
Create a tree node object and so add it to the chosen node within the management.
Below is that the code to try to to that:
Dim tnode As New TreeNode(textBox1.Text)
treeView1.SelectedNode.Nodes.Add(tnode)
treeView1.ExpandAll()
If treeView1.SelectedNode.Nodes.Count > 1 And treeView1.SelectedNode.ForeColor <> Color.Blue Then
treeView1.SelectedNode.ForeColor = Color.Brown
End If
2. How to add a sibling to a selected node
To add a sibling to a specific node (provided it's a parent node)
Below code implements this concept:
Dim tnode As New TreeNode(textBox1.Text)
tnode.ForeColor = Color.Brown
treeView1.SelectedNode.Parent.Nodes.Add(tnode)
3. Delete a particular selected node
Use the remove methodology to delete the chosen node.
treeView1.SelectedNode.Remove()
4. Use of context Menu
All the on top of 3 cases are often performed via use of context menu also.
Thus a user can use this control for displaying the hierarchical structures.
HostForLIFE.eu Visual Studio 2015 Hosting
HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.