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.
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.
}
}
Anonymous User
21-Feb-2019Sushant Mishra
17-Jul-2017I am really helpful to you, for sharing a post like this.