How to build a tree view using C#
The following snippet helps to build a simple tree view.
Tree View Control
Add a Tree View Control to the form
The following code adds a simple treeview with a root node and two children
private void AddTreeViewControls()
{
treeView1.Nodes.Add("Root","XYZ Autombiles");
treeView1.Nodes["Root"].Nodes.Add("PV", "Passenger Vehicles");
treeView1.Nodes["Root"].Nodes.Add("CV", "Commercial Vehicles");
}
The nodes are added using the Add method – the first parameter is the Key and the second is the node text. The child nodes are added to the root using the Key
treeView1.Nodes["Root"]
No comments:
Post a Comment