Windows Phone Developers

Tuesday, February 17, 2009

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");

}

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

2 comments:

  1. This is simple thing what you've shown. What we require is the data binding to and from XML file to this tree control in C# forms application

    ReplyDelete
  2. this bastard before my comment should have specified it

    ReplyDelete