Home > DeveloperSection > Articles > How to use TreeView Control and WebBrowser Control in CSharp .NET

How to use TreeView Control and WebBrowser Control in CSharp .NET


C# C# 
Ratings:
0 Comment(s)
 7817  View(s)
Rate this:

How to use TreeView Control and WebBrowser Control in C#.Net

TreeViews have plus symbols that we can click. To add one to our form find tree view control on tool box and use it in your form.

Now, to add Nodes to the TreeView, click the TreeView to select it. Then locate the Nodes property in the properties area

Click the button with the three dots in it, just to the right of Collection. You'll then see the TreeNode Editor Dialogue box.

There are two types of Nodes you can Add - a Root Node and a Child Node. Click the Add Root button.

 

 

Set the following properties:

Name: Google
Tag: http://www.google.com
Text: Google

Name: Yahoo
Tag: http://www.yahoo.com
Text: Yahoo!

Name: Bing
Tag: http://www.bing.com
Text: Bing

 

 

Now, add a webBrowser to the form.

 

Now write the code for TreeView control’s at NodeMouseClick Event.

private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)

        {

            TreeNode nName = e.Node;

            string webPage = "";

            webPage = (string)nName.Tag;

//seting webPage to node tag string.

            if (webPage != "")

            {

                webBrowser1.Navigate(webPage);

//Navigating to webPage address.

            }

        }   

 


Don't want to miss updates? Please click the below button!

Follow MindStick