Windows Phone Developers

Tuesday, February 17, 2009

How to add nodes to the tree view control using C#

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"]


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment