Friday, February 8, 2008

How to add nodes to a TreeView WebBrowser control by using Visual C# .NET


Download the IE Web Controls here and follow instructions in ReadMe.txt to install

1. Add the TreeView Control to the WebForm1.aspx.
2. Click F7 and you will be in Code View

using Microsoft.Web.UI.WebControls;
....
.....
......

TreeNode head ;
TreeNode child;
private void Button1_Click(object sender, System.EventArgs e)
{
head = new TreeNode();
head.Text = "My First Tree Node";
TreeView1.Nodes.Add(head);//Adding Nodes

child = new TreeNode();
child.Text = "My second Tree Node";
head.Nodes.Add(child); //Adding Nodes


}

It is as simple as it seems, you can display objects and XML data using this.


Useful Resources: