articles

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

Anonymous User11687 02-Aug-2010

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.

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

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

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

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

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

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

 

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

 

Now, add a webBrowser to the form.

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

 

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

privatevoid 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.
            }
        }   

 

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

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



Updated 04-Mar-2020
I am a content writter !

Leave Comment

Comments

Liked By