Thursday 1 December 2011

How to use Treeview designer in C# Application

C# Treeview designer example

Treeview control gives a nice hierarchical view for the users of a given concept. The following example shows how to create a simple tree-view control using the designer

Add a Tree View Control to the form
































Select the TreeView Tasks from the control
Add the root item – XYZ Automobiles







Click the root item and then click on the Add Child to add children. Repeat the steps to add more children


 
 
 
 
 
 
 
 
 
 
The form will be displayed as shown below













The above can be done through C# code as shown below:
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");
}

0 comments:

Post a Comment